summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_debug.c
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2022-05-12 09:28:06 +0200
committerDonatas Abraitis <donatas@opensourcerouting.org>2022-05-12 09:28:06 +0200
commit7aad5e6a38cf2437d6df022199658f855f48f897 (patch)
tree1bbdfcb7c6f65966214c1f2056199a4a161bb604 /bgpd/bgp_debug.c
parentbgpd: Check argv_find() value instead of the index (diff)
downloadfrr-7aad5e6a38cf2437d6df022199658f855f48f897.tar.xz
frr-7aad5e6a38cf2437d6df022199658f855f48f897.zip
bgpd: Check and validate return value for str2ipaddr()
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
Diffstat (limited to 'bgpd/bgp_debug.c')
-rw-r--r--bgpd/bgp_debug.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c
index 74f9ca49d..7712274b5 100644
--- a/bgpd/bgp_debug.c
+++ b/bgpd/bgp_debug.c
@@ -642,10 +642,16 @@ static int bgp_debug_parse_evpn_prefix(struct vty *vty, struct cmd_token **argv,
memset(&ip, 0, sizeof(struct ipaddr));
if (argv_find(argv, argc, "mac", &mac_idx))
- (void)prefix_str2mac(argv[mac_idx + 1]->arg, &mac);
+ if (!prefix_str2mac(argv[mac_idx + 1]->arg, &mac)) {
+ vty_out(vty, "%% Malformed MAC address\n");
+ return CMD_WARNING;
+ }
if (argv_find(argv, argc, "ip", &ip_idx))
- str2ipaddr(argv[ip_idx + 1]->arg, &ip);
+ 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);
@@ -653,7 +659,10 @@ static int bgp_debug_parse_evpn_prefix(struct vty *vty, struct cmd_token **argv,
memset(&ip, 0, sizeof(struct ipaddr));
if (argv_find(argv, argc, "ip", &ip_idx))
- str2ipaddr(argv[ip_idx + 1]->arg, &ip);
+ 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);