From 392701f80a31cf1b3781f9931ba398a1944894ef Mon Sep 17 00:00:00 2001 From: Hans Dedecker Date: Mon, 4 Jun 2018 21:49:52 +0200 Subject: [PATCH] odhcpd: fix passing possible negative parameter Prevent passing negative argument to read; detected by Coverity in CID1412381 Signed-off-by: Hans Dedecker --- src/odhcpd.c | 3 +++ 1 file changed, 3 insertions(+) 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); -- 2.30.2