]> sourceware.org Git - glibc.git/commitdiff
Check length of ifname before copying it into to ifreq structure.
authorSteve Ellcey <sellcey@caviumnetworks.com>
Wed, 15 Nov 2017 16:58:48 +0000 (08:58 -0800)
committerSteve Ellcey <sellcey@caviumnetworks.com>
Wed, 15 Nov 2017 16:58:48 +0000 (08:58 -0800)
[BZ #22442]
* sysdeps/unix/sysv/linux/if_index.c (__if_nametoindex):
Check if ifname is too long.

ChangeLog
sysdeps/unix/sysv/linux/if_index.c

index c26eac8d32caade7d70c575ed124a2ac8fb87538..e10db6016df6be6cf4bafd37659a1109e5b5d2d8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-11-15  Steve Ellcey  <sellcey@cavium.com>
+
+       [BZ #22442]
+       * sysdeps/unix/sysv/linux/if_index.c (__if_nametoindex):
+       Check if ifname is too long.
+
 2017-11-15  Luke Shumaker  <lukeshu@parabola.nu>
 
        * sysdeps/unix/sysv/linux/epoll_wait.c: Include <sysdep-cancel.h>.
index 56f3f136cb4284c52b140bbff59c7600f09be27e..e7ca27bc18265f5d18f01875cba0b33785d50fea 100644 (file)
@@ -43,6 +43,12 @@ __if_nametoindex (const char *ifname)
   if (fd < 0)
     return 0;
 
+  if (strlen (ifname) >= IFNAMSIZ)
+    {
+      __set_errno (ENODEV);
+      return 0;
+    }
+
   strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
   if (__ioctl (fd, SIOCGIFINDEX, &ifr) < 0)
     {
This page took 0.081878 seconds and 5 git commands to generate.