]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
elf: Count components of the expanded path in _dl_init_path [BZ #22607]
authorFlorian Weimer <fweimer@redhat.com>
Thu, 14 Dec 2017 14:05:57 +0000 (15:05 +0100)
committerAurelien Jarno <aurelien@aurel32.net>
Sat, 16 Dec 2017 11:58:10 +0000 (12:58 +0100)
(cherry picked from commit 3ff3dfa5af313a6ea33f3393916f30eece4f0171)

ChangeLog
NEWS
elf/dl-load.c

index 772b96ee42b3521276c072ecd7f6651b1e3b3cb1..55a17414ab0d6eaf4d2d94aba4a133ac8efbb614 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-12-14  Florian Weimer  <fweimer@redhat.com>
+
+       [BZ #22607]
+       CVE-2017-1000409
+       * elf/dl-load.c (_dl_init_paths): Compute number of components in
+       the expanded path string.
+
 2017-12-14  Florian Weimer  <fweimer@redhat.com>
 
        [BZ #22606]
diff --git a/NEWS b/NEWS
index 437b9ee00f774b9b7d238366ddc85e0d6b351ca0..2c49212cb519e60675dbdad527055eea4d7eed69 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -49,6 +49,12 @@ Security related changes:
   it is mentioned here only because of the CVE assignment.)  Reported by
   Qualys.
 
+  CVE-2017-1000409: Buffer overflow in _dl_init_paths due to miscomputation
+  of the number of search path components.  (This is not a security
+  vulnerability per se because no trust boundary is crossed if the fix for
+  CVE-2017-1000366 has been applied, but it is mentioned here only because
+  of the CVE assignment.)  Reported by Qualys.
+
 The following bugs are resolved with this release:
 
   [16750] ldd: Never run file directly.
index b3b0b37bf9ade899cd4586bcf726a82f809cadf8..621403c05fc473a44cbd05bb7a4bae683652d43a 100644 (file)
@@ -776,8 +776,6 @@ _dl_init_paths (const char *llp)
 
   if (llp != NULL && *llp != '\0')
     {
-      size_t nllp;
-      const char *cp = llp;
       char *llp_tmp;
 
 #ifdef SHARED
@@ -800,13 +798,10 @@ _dl_init_paths (const char *llp)
 
       /* Decompose the LD_LIBRARY_PATH contents.  First determine how many
         elements it has.  */
-      nllp = 1;
-      while (*cp)
-       {
-         if (*cp == ':' || *cp == ';')
-           ++nllp;
-         ++cp;
-       }
+      size_t nllp = 1;
+      for (const char *cp = llp_tmp; *cp != '\0'; ++cp)
+       if (*cp == ':' || *cp == ';')
+         ++nllp;
 
       env_path_list.dirs = (struct r_search_path_elem **)
        malloc ((nllp + 1) * sizeof (struct r_search_path_elem *));