1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +03:00

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

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