summaryrefslogtreecommitdiffstats
path: root/zebra/ipforward_proc.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-12-05 02:51:34 +0100
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-12-05 03:28:19 +0100
commit116e176d99e8dd5a586196feee3df3d8eebed0ee (patch)
treebf33b22491bcb4d7d9e1bc0e88086853dc1cb029 /zebra/ipforward_proc.c
parentbgpd: Tell the compiler we don't care about the return code for peer_sort (diff)
downloadfrr-116e176d99e8dd5a586196feee3df3d8eebed0ee.tar.xz
frr-116e176d99e8dd5a586196feee3df3d8eebed0ee.zip
bgpd, zebra: Use sscanf return value
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'zebra/ipforward_proc.c')
-rw-r--r--zebra/ipforward_proc.c12
1 files changed, 9 insertions, 3 deletions
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;
}