diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2018-04-14 21:15:42 +0200 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2018-04-14 21:17:40 +0200 |
commit | df1625da2dd5fd0496c0c9d92490eba0cb9117f8 (patch) | |
tree | 54efd227d60fefd2d5375d62f0c216f8ce159559 /system-linux.c | |
parent | 209c5080e6dc64ee676f790eeaa65e204e978fc8 (diff) |
system-linux: check ioctl return value in system_if_flags()
Detected by Coverity in CID 1433760
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'system-linux.c')
-rw-r--r-- | system-linux.c | 4 |
1 files changed, 3 insertions, 1 deletions
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); |