From df1625da2dd5fd0496c0c9d92490eba0cb9117f8 Mon Sep 17 00:00:00 2001 From: Hans Dedecker Date: Sat, 14 Apr 2018 21:15:42 +0200 Subject: [PATCH] system-linux: check ioctl return value in system_if_flags() Detected by Coverity in CID 1433760 Signed-off-by: Hans Dedecker --- system-linux.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); -- 2.25.1