>From 400821e6eab2f7803d35862d6e03b9689f7cc18c Mon Sep 17 00:00:00 2001
From: Nathan Hintz <nlhi...@hotmail.com>
Date: Sun, 20 Oct 2013 14:02:48 -0700
Subject: [PATCH,v2 1/2] 6relayd: verify fd is valid before use

Signed-off-by: Nathan Hintz <nlhi...@hotmail.com>
---
 src/6relayd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/6relayd.c b/src/6relayd.c
index fcfecb7..32ead14 100644
--- a/src/6relayd.c
+++ b/src/6relayd.c
@@ -403,6 +403,9 @@ int relayd_get_interface_mtu(const char *ifname)
     snprintf(buf, sizeof(buf), sysctl_pattern, ifname);
 
     int fd = open(buf, O_RDONLY);
+    if (fd < 0)
+        return -1;
+
     ssize_t len = read(fd, buf, sizeof(buf) - 1);
     close(fd);
 
-- 
1.8.4.2                                           
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to