diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/if_index.c | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog index c26eac8d32..e10db6016d 100644 --- 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>. diff --git a/sysdeps/unix/sysv/linux/if_index.c b/sysdeps/unix/sysv/linux/if_index.c index 56f3f136cb..e7ca27bc18 100644 --- a/sysdeps/unix/sysv/linux/if_index.c +++ b/sysdeps/unix/sysv/linux/if_index.c @@ -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) { |