crosstool-ng/packages/glibc/2.15/0046-if_nametoindex-size-check.patch
Alexey Neyman 387c8d8e2c First batch of fixes
- Incompatible function type for ifunc alias
- Multiple statements macro expansion in strftime
- if_nametoindex size checking

Signed-off-by: Alexey Neyman <stilor@att.net>
2018-05-12 13:03:29 -07:00

30 lines
777 B
Diff

commit 2180fee114b778515b3f560e5ff1e795282e60b0
Author: Steve Ellcey <sellcey@caviumnetworks.com>
Date: Wed Nov 15 08:58:48 2017 -0800
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.
---
sysdeps/unix/sysv/linux/if_index.c | 6 ++++++
1 file changed, 6 insertions(+)
--- a/sysdeps/unix/sysv/linux/if_index.c
+++ b/sysdeps/unix/sysv/linux/if_index.c
@@ -54,6 +54,12 @@
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)
{