From: Hans Dedecker Date: Sat, 14 Apr 2018 19:15:42 +0000 (+0200) Subject: system-linux: check ioctl return value in system_if_flags() X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=df1625da2dd5fd0496c0c9d92490eba0cb9117f8;p=oweals%2Fnetifd.git system-linux: check ioctl return value in system_if_flags() Detected by Coverity in CID 1433760 Signed-off-by: Hans Dedecker --- diff --git a/system-linux.c b/system-linux.c index 9933201..0b594f6 100644 --- a/system-linux.c +++ b/system-linux.c @@ -781,7 +781,9 @@ static int system_if_flags(const char *ifname, unsigned add, unsigned rem) memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); - ioctl(sock_ioctl, SIOCGIFFLAGS, &ifr); + if (ioctl(sock_ioctl, SIOCGIFFLAGS, &ifr) < 0) + return -1; + ifr.ifr_flags |= add; ifr.ifr_flags &= ~rem; return ioctl(sock_ioctl, SIOCSIFFLAGS, &ifr);