25845f
commit dbba87d531ad3ea372eba6cb56436a231ca7fb32
25845f
Author: Dmitry V. Levin <ldv@altlinux.org>
25845f
Date:   Wed Dec 27 22:12:51 2017 +0000
25845f
25845f
    elf: check for rpath emptiness before making a copy of it
25845f
25845f
    * elf/dl-load.c (decompose_rpath): Check for rpath emptiness before
25845f
    making a copy of it.
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
@@ -550,7 +550,6 @@ decompose_rpath (struct r_search_path_st
25845f
 {
25845f
   /* Make a copy we can work with.  */
25845f
   const char *where = l->l_name;
25845f
-  char *copy;
25845f
   char *cp;
25845f
   struct r_search_path_elem **result;
25845f
   size_t nelems;
25845f
@@ -589,22 +588,21 @@ decompose_rpath (struct r_search_path_st
25845f
       while (*inhp != '\0');
25845f
     }
25845f
 
25845f
+  /* Ignore empty rpaths.  */
25845f
+  if (*rpath == '\0')
25845f
+    {
25845f
+      sps->dirs = (struct r_search_path_elem **) -1;
25845f
+      return false;
25845f
+    }
25845f
+
25845f
   /* Make a writable copy.  */
25845f
-  copy = local_strdup (rpath);
25845f
+  char *copy = local_strdup (rpath);
25845f
   if (copy == NULL)
25845f
     {
25845f
       errstring = N_("cannot create RUNPATH/RPATH copy");
25845f
       goto signal_error;
25845f
     }
25845f
 
25845f
-  /* Ignore empty rpaths.  */
25845f
-  if (*copy == 0)
25845f
-    {
25845f
-      free (copy);
25845f
-      sps->dirs = (struct r_search_path_elem **) -1;
25845f
-      return false;
25845f
-    }
25845f
-
25845f
   /* Count the number of necessary elements in the result array.  */
25845f
   nelems = 0;
25845f
   for (cp = copy; *cp != '\0'; ++cp)