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