summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2018-06-04 21:49:52 +0200
committerHans Dedecker <dedeckeh@gmail.com>2018-06-04 21:54:57 +0200
commit392701f80a31cf1b3781f9931ba398a1944894ef (patch)
treefd837ed836e377640bc635549944da5901f369c2 /src
parent029123bc5f2bd9429abc27c987e40af7799238a2 (diff)
odhcpd: fix passing possible negative parameter
Prevent passing negative argument to read; detected by Coverity in CID1412381 Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/odhcpd.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/odhcpd.c b/src/odhcpd.c
index 0e0002d..7c6c144 100644
--- a/src/odhcpd.c
+++ b/src/odhcpd.c
@@ -128,6 +128,9 @@ int odhcpd_get_interface_config(const char *ifname, const char *what)
snprintf(buf, sizeof(buf), sysctl_pattern, ifname, what);
int fd = open(buf, O_RDONLY);
+ if (fd < 0)
+ return -1;
+
ssize_t len = read(fd, buf, sizeof(buf) - 1);
close(fd);