]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd, zebra: Use sscanf return value
authorDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 5 Dec 2017 01:51:34 +0000 (20:51 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 5 Dec 2017 02:28:19 +0000 (21:28 -0500)
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgp_routemap.c
zebra/ipforward_proc.c

index 30397f84877d45bc02925299f6a6b19fdef7a231..8c9f9f65ca4e4b3894e6d27ae7d2435b41ecaca1 100644 (file)
@@ -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);
index 2834eeeb9cc51f62921c9f95796f21030a56b481..f823ec4384c9eedea0efa81b1029a41b33eaca1d 100644 (file)
@@ -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;
 }