public inbox for libc-stable@sourceware.org
 help / color / mirror / Atom feed
* [2.26 COMMITTED] Check length of ifname before copying it into to ifreq structure.
@ 2018-01-01  0:00 Florian Weimer
  0 siblings, 0 replies; only message in thread
From: Florian Weimer @ 2018-01-01  0:00 UTC (permalink / raw)
  To: libc-stable

From: Steve Ellcey <sellcey@caviumnetworks.com>

	[BZ #22442]
	* sysdeps/unix/sysv/linux/if_index.c (__if_nametoindex):
	Check if ifname is too long.

(cherry picked from commit 2180fee114b778515b3f560e5ff1e795282e60b0)

2017-11-15  Steve Ellcey  <sellcey@cavium.com>

	[BZ #22442]
	* sysdeps/unix/sysv/linux/if_index.c (__if_nametoindex):
	Check if ifname is too long.

diff --git a/NEWS b/NEWS
index db43d87ee0..48d28e166a 100644
--- a/NEWS
+++ b/NEWS
@@ -120,6 +120,7 @@ The following bugs are resolved with this release:
   [22299] x86-64: Don't set GLRO(dl_platform) to NULL
   [22320] glob: Fix one-byte overflow (CVE-2017-15670)
   [22321] sysconf: Fix missing definition of UIO_MAXIOV on Linux
+  [22442] if_nametoindex: Check length of ifname before copying it
   [22322] libc: [mips64] wrong bits/long-double.h installed
   [22325] glibc: Memory leak in glob with GLOB_TILDE (CVE-2017-15671)
   [22342] NSCD not properly caching netgroup
diff --git a/sysdeps/unix/sysv/linux/if_index.c b/sysdeps/unix/sysv/linux/if_index.c
index 8ba5eae781..a874634d52 100644
--- a/sysdeps/unix/sysv/linux/if_index.c
+++ b/sysdeps/unix/sysv/linux/if_index.c
@@ -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)
     {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-07-04 11:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-01  0:00 [2.26 COMMITTED] Check length of ifname before copying it into to ifreq structure Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).