diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-12-05 02:51:34 +0100 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-12-05 03:28:19 +0100 |
commit | 116e176d99e8dd5a586196feee3df3d8eebed0ee (patch) | |
tree | bf33b22491bcb4d7d9e1bc0e88086853dc1cb029 | |
parent | bgpd: Tell the compiler we don't care about the return code for peer_sort (diff) | |
download | frr-116e176d99e8dd5a586196feee3df3d8eebed0ee.tar.xz frr-116e176d99e8dd5a586196feee3df3d8eebed0ee.zip |
bgpd, zebra: Use sscanf return value
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
-rw-r--r-- | bgpd/bgp_routemap.c | 5 | ||||
-rw-r--r-- | zebra/ipforward_proc.c | 12 |
2 files changed, 13 insertions, 4 deletions
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 30397f848..8c9f9f65c 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -2082,7 +2082,10 @@ static void *route_set_aggregator_as_compile(const char *arg) aggregator = XCALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(struct aggregator)); - sscanf(arg, "%s %s", as, address); + if (sscanf(arg, "%s %s", as, address) != 2) { + XFREE(MTYPE_ROUTE_MAP_COMPILED, aggregator); + return NULL; + } aggregator->as = strtoul(as, NULL, 10); ret = inet_aton(address, &aggregator->address); diff --git a/zebra/ipforward_proc.c b/zebra/ipforward_proc.c index 2834eeeb9..f823ec438 100644 --- a/zebra/ipforward_proc.c +++ b/zebra/ipforward_proc.c @@ -42,6 +42,7 @@ static void dropline(FILE *fp) int ipforward(void) { + int ret = 0; FILE *fp; int ipforwarding = 0; char buf[10]; @@ -58,11 +59,11 @@ int ipforward(void) 1 => ip forwarding enabled 2 => ip forwarding off. */ if (fgets(buf, 6, fp)) - sscanf(buf, "Ip: %d", &ipforwarding); + ret = sscanf(buf, "Ip: %d", &ipforwarding); fclose(fp); - if (ipforwarding == 1) + if (ret == 1 && ipforwarding == 1) return 1; return 0; @@ -127,6 +128,7 @@ char proc_ipv6_forwarding[] = "/proc/sys/net/ipv6/conf/all/forwarding"; int ipforward_ipv6(void) { + int ret = 0; FILE *fp; char buf[5]; int ipforwarding = 0; @@ -137,9 +139,13 @@ int ipforward_ipv6(void) return -1; if (fgets(buf, 2, fp)) - sscanf(buf, "%d", &ipforwarding); + ret = sscanf(buf, "%d", &ipforwarding); fclose(fp); + + if (ret != 1) + return 0; + return ipforwarding; } |