system-linux: check ioctl return value in system_if_flags()
[project/netifd.git] / system-linux.c
index 9933201..0b594f6 100644 (file)
@@ -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);