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:
@ -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;
|
||||
|
Reference in New Issue
Block a user