diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-04-03 18:06:15 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-04-03 18:06:15 +0200 |
commit | 511ed56f2e792bea5e7145e1d5d5c93b9f47c41f (patch) | |
tree | 42ac6995af1c95abf73c77e4811ee3271a5232e0 /sysdeps | |
parent | e88ecbbfe836db5b6da809108759de4ca56be5e7 (diff) | |
download | glibc-511ed56f2e792bea5e7145e1d5d5c93b9f47c41f.tar.gz |
hurd: Fix buffer overrun in __if_nametoindex
and building with mainline GCC which reports it.
* sysdeps/mach/hurd/if_index.c (__if_nametoindex): Always end
ifr.fr_name with a NUL caracter.
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/mach/hurd/if_index.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sysdeps/mach/hurd/if_index.c b/sysdeps/mach/hurd/if_index.c index d637353d74..7f647b7036 100644 --- a/sysdeps/mach/hurd/if_index.c +++ b/sysdeps/mach/hurd/if_index.c @@ -37,7 +37,9 @@ __if_nametoindex (const char *ifname) if (fd < 0) return 0; - strncpy (ifr.ifr_name, ifname, IFNAMSIZ); + strncpy (ifr.ifr_name, ifname, IFNAMSIZ - 1); + ifr.ifr_name[IFNAMESIZ - 1] = '\0'; + if (__ioctl (fd, SIOCGIFINDEX, &ifr) < 0) { int saved_errno = errno; |