diff options
author | Steve Ellcey <sellcey@caviumnetworks.com> | 2017-11-15 08:58:48 -0800 |
---|---|---|
committer | Steve Ellcey <sellcey@caviumnetworks.com> | 2017-11-15 08:58:48 -0800 |
commit | 2180fee114b778515b3f560e5ff1e795282e60b0 (patch) | |
tree | f6c4c852095296d6d95885254e2582e96e028cce | |
parent | cad7ca390879f2a8250e58bf5009a00b887a19b7 (diff) | |
download | glibc-2180fee114b778515b3f560e5ff1e795282e60b0.zip glibc-2180fee114b778515b3f560e5ff1e795282e60b0.tar.gz glibc-2180fee114b778515b3f560e5ff1e795282e60b0.tar.bz2 |
Check length of ifname before copying it into to ifreq structure.
[BZ #22442]
* sysdeps/unix/sysv/linux/if_index.c (__if_nametoindex):
Check if ifname is too long.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/if_index.c | 6 |
2 files changed, 12 insertions, 0 deletions
@@ -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 56f3f13..e7ca27b 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) { |