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.
This commit is contained in:
Steve Ellcey 2017-11-15 08:58:48 -08:00
parent cad7ca3908
commit 2180fee114
2 changed files with 12 additions and 0 deletions

View File

@ -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>.

View 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)
{