25845f
commit 3ff3dfa5af313a6ea33f3393916f30eece4f0171
25845f
Author: Florian Weimer <fweimer@redhat.com>
25845f
Date:   Thu Dec 14 15:05:57 2017 +0100
25845f
25845f
    elf: Count components of the expanded path in _dl_init_path [BZ #22607]
25845f
25845f
Index: glibc-2.17-c758a686/elf/dl-load.c
25845f
===================================================================
25845f
--- glibc-2.17-c758a686.orig/elf/dl-load.c
25845f
+++ glibc-2.17-c758a686/elf/dl-load.c
25845f
@@ -829,8 +829,6 @@ _dl_init_paths (const char *llp)
25845f
 
25845f
   if (llp != NULL && *llp != '\0')
25845f
     {
25845f
-      size_t nllp;
25845f
-      const char *cp = llp;
25845f
       char *llp_tmp;
25845f
 
25845f
 #ifdef SHARED
25845f
@@ -853,13 +851,10 @@ _dl_init_paths (const char *llp)
25845f
 
25845f
       /* Decompose the LD_LIBRARY_PATH contents.  First determine how many
25845f
 	 elements it has.  */
25845f
-      nllp = 1;
25845f
-      while (*cp)
25845f
-	{
25845f
-	  if (*cp == ':' || *cp == ';')
25845f
-	    ++nllp;
25845f
-	  ++cp;
25845f
-	}
25845f
+      size_t nllp = 1;
25845f
+      for (const char *cp = llp_tmp; *cp != '\0'; ++cp)
25845f
+	if (*cp == ':' || *cp == ';')
25845f
+	  ++nllp;
25845f
 
25845f
       env_path_list.dirs = (struct r_search_path_elem **)
25845f
 	malloc ((nllp + 1) * sizeof (struct r_search_path_elem *));