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:
parent
cad7ca3908
commit
2180fee114
|
@ -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>.
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue