1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-01 10:06:57 +03:00

CVE-2018-19591: if_nametoindex: Fix descriptor for overlong name [BZ #23927]

This commit is contained in:
Florian Weimer
2018-11-27 16:12:43 +01:00
parent 979cfed05d
commit d527c860f5
3 changed files with 16 additions and 6 deletions

View File

@ -38,11 +38,6 @@ __if_nametoindex (const char *ifname)
return 0;
#else
struct ifreq ifr;
int fd = __opensock ();
if (fd < 0)
return 0;
if (strlen (ifname) >= IFNAMSIZ)
{
__set_errno (ENODEV);
@ -50,6 +45,12 @@ __if_nametoindex (const char *ifname)
}
strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
int fd = __opensock ();
if (fd < 0)
return 0;
if (__ioctl (fd, SIOCGIFINDEX, &ifr) < 0)
{
int saved_errno = errno;