about summary refs log tree commit diff
path: root/elf/dl-load.c
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 14:47:11 +0100
commita8920e694ab23f25435329b2365efa5ca7ac64bd (patch)
treee694a3b723d784d1aecebc33bf895c0f485243f8 /elf/dl-load.c
parent778a7c1825abe6273562617836c49b9573c394e8 (diff)
downloadglibc-a8920e694ab23f25435329b2365efa5ca7ac64bd.tar.gz
glibc-a8920e694ab23f25435329b2365efa5ca7ac64bd.tar.xz
glibc-a8920e694ab23f25435329b2365efa5ca7ac64bd.zip
elf: Count components of the expanded path in _dl_init_path [BZ #22607]
(cherry picked from commit 3ff3dfa5af313a6ea33f3393916f30eece4f0171)
Diffstat (limited to 'elf/dl-load.c')
-rw-r--r--elf/dl-load.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c
index c8cf96e226..92303b08e6 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 *));