about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2017-12-14 15:05:57 +0100
committerAurelien Jarno <aurelien@aurel32.net>2017-12-16 19:22:10 +0100
commitc5b38f2ecec6facf818e3c50ad014be05b52c179 (patch)
tree9f21779a4a65fa6c573ebf0d825177a85d7c5901
parent28aa53341abbc5843fc78f283c397d11d74a33db (diff)
downloadglibc-c5b38f2ecec6facf818e3c50ad014be05b52c179.tar.gz
glibc-c5b38f2ecec6facf818e3c50ad014be05b52c179.tar.xz
glibc-c5b38f2ecec6facf818e3c50ad014be05b52c179.zip
elf: Count components of the expanded path in _dl_init_path [BZ #22607]
(cherry picked from commit 3ff3dfa5af313a6ea33f3393916f30eece4f0171)
-rw-r--r--ChangeLog7
-rw-r--r--NEWS6
-rw-r--r--elf/dl-load.c13
3 files changed, 17 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 90e4444444..2c2e9d5b19 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 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]
 	CVE-2017-1000408
 	* elf/dl-load.c (system_dirs): Update comment.
diff --git a/NEWS b/NEWS
index 9de14ffba0..9e20117a81 100644
--- a/NEWS
+++ b/NEWS
@@ -39,6 +39,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:
 
   [20790] Fix rpcgen buffer overrun
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 0d46c16ea7..64f55145a2 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -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 *));