utils: fix possibly unterminated ifname string
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 29 Oct 2015 09:53:48 +0000 (10:53 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 29 Oct 2015 09:53:48 +0000 (10:53 +0100)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
iwinfo_utils.c

index 3b993d124884a061fe8444ac8a871491e03bb379..3090c4cde4a3711fb45b7af22d0d9a52adf5371d 100644 (file)
@@ -81,7 +81,7 @@ int iwinfo_ifup(const char *ifname)
 {
        struct ifreq ifr;
 
-       strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+       strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
 
        if (iwinfo_ioctl(SIOCGIFFLAGS, &ifr))
                return 0;
@@ -95,7 +95,7 @@ int iwinfo_ifdown(const char *ifname)
 {
        struct ifreq ifr;
 
-       strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+       strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
 
        if (iwinfo_ioctl(SIOCGIFFLAGS, &ifr))
                return 0;
@@ -109,7 +109,7 @@ int iwinfo_ifmac(const char *ifname)
 {
        struct ifreq ifr;
 
-       strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+       strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
 
        if (iwinfo_ioctl(SIOCGIFHWADDR, &ifr))
                return 0;