]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
CVE-2018-19591: if_nametoindex: Fix descriptor for overlong name [BZ #23927]
authorFlorian Weimer <fweimer@redhat.com>
Tue, 27 Nov 2018 15:12:43 +0000 (16:12 +0100)
committerPranav Kant <prka@google.com>
Fri, 12 Jan 2024 23:20:06 +0000 (23:20 +0000)
ChangeLog
NEWS
sysdeps/unix/sysv/linux/if_index.c

index 7cf21922f0da892576f79d359e658c243ed17a25..0306f0caaff6d0d50acc6ab529d7ad11a1dfa1d0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
        * resolv/tst-resolv-nondecimal.c: Likewise.
        * sysdeps/posix/getaddrinfo.c (gaih_inet): Call __inet_aton_exact.
 
+2018-11-27  Florian Weimer  <fweimer@redhat.com>
+
+       [BZ #23927]
+       CVE-2018-19591
+       * sysdeps/unix/sysv/linux/if_index.c (__if_nametoindex): Avoid
+       descriptor leak in case of ENODEV error.
+
 2018-05-18  Joseph Myers  <joseph@codesourcery.com>
 
        [BZ #22639]
@@ -38,6 +45,7 @@
        * time/tst-y2039.c: New file.
        * time/Makefile (tests): Add tst-y2039.
 
+
 2018-02-12  Zack Weinberg  <zackw@panix.com>
 
        [BZ #19239]
diff --git a/NEWS b/NEWS
index 162a845cc0df6212764d837823d9beb3ce524b48..46b5a2d8d8b29a2ed9b05b259db508f1b171b5e0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -32,6 +32,10 @@ Security related changes:
   addresses with arbitrary trailing characters, potentially leading to data
   or command injection issues in applications.
 
+  CVE-2018-19591: A file descriptor leak in if_nametoindex can lead to a
+  denial of service due to resource exhaustion when processing getaddrinfo
+  calls with crafted host names.  Reported by Guido Vranken.
+
   CVE-2017-18269: An SSE2-based memmove implementation for the i386
   architecture could corrupt memory.  Reported by Max Horn.
 
index e3d08982d9931108b8965d07dbded44bcb2f5ff8..782fc5e1750e9eadcc2dbfff2d62828ac06973ad 100644 (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;