diff options
| author | Donald Sharp <donaldsharp72@gmail.com> | 2022-05-13 07:35:57 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-13 07:35:57 -0400 |
| commit | 69df174216b5829d3075765e0dba30d16f20e25c (patch) | |
| tree | 0941a78075e61004c563f5f775aa4d739d2587d3 /bgpd/bgp_debug.c | |
| parent | a4df11489c5058c873eceaadeb6dbb3e9e74e956 (diff) | |
| parent | 7aad5e6a38cf2437d6df022199658f855f48f897 (diff) | |
Merge pull request #11188 from opensourcerouting/fix/argv_find
bgpd: Cleanup
Diffstat (limited to 'bgpd/bgp_debug.c')
| -rw-r--r-- | bgpd/bgp_debug.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index 0993d6de57..7712274b58 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -627,8 +627,8 @@ static int bgp_debug_parse_evpn_prefix(struct vty *vty, struct cmd_token **argv, int argc, struct prefix **argv_pp) { struct prefix *argv_p; - struct ethaddr mac; - struct ipaddr ip; + struct ethaddr mac = {}; + struct ipaddr ip = {}; int evpn_type = 0; int mac_idx = 0; int ip_idx = 0; @@ -641,19 +641,28 @@ static int bgp_debug_parse_evpn_prefix(struct vty *vty, struct cmd_token **argv, if (evpn_type == BGP_EVPN_MAC_IP_ROUTE) { memset(&ip, 0, sizeof(struct ipaddr)); - argv_find(argv, argc, "mac", &mac_idx); - (void)prefix_str2mac(argv[mac_idx + 1]->arg, &mac); + if (argv_find(argv, argc, "mac", &mac_idx)) + if (!prefix_str2mac(argv[mac_idx + 1]->arg, &mac)) { + vty_out(vty, "%% Malformed MAC address\n"); + return CMD_WARNING; + } - argv_find(argv, argc, "ip", &ip_idx); - str2ipaddr(argv[ip_idx + 1]->arg, &ip); + if (argv_find(argv, argc, "ip", &ip_idx)) + if (str2ipaddr(argv[ip_idx + 1]->arg, &ip) != 0) { + vty_out(vty, "%% Malformed IP address\n"); + return CMD_WARNING; + } build_evpn_type2_prefix((struct prefix_evpn *)argv_p, &mac, &ip); } else if (evpn_type == BGP_EVPN_IMET_ROUTE) { memset(&ip, 0, sizeof(struct ipaddr)); - argv_find(argv, argc, "ip", &ip_idx); - str2ipaddr(argv[ip_idx + 1]->arg, &ip); + if (argv_find(argv, argc, "ip", &ip_idx)) + if (str2ipaddr(argv[ip_idx + 1]->arg, &ip) != 0) { + vty_out(vty, "%% Malformed IP address\n"); + return CMD_WARNING; + } build_evpn_type3_prefix((struct prefix_evpn *)argv_p, ip.ipaddr_v4); |
