]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
elf: check for rpath emptiness before making a copy of it
authorDmitry V. Levin <ldv@altlinux.org>
Wed, 27 Dec 2017 22:12:51 +0000 (22:12 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 1 Jan 2018 20:37:32 +0000 (20:37 +0000)
* elf/dl-load.c (decompose_rpath): Check for rpath emptiness before
making a copy of it.

ChangeLog
elf/dl-load.c

index 22a4a9f557740b03640a3e6fbe18750d162dda40..1dd4b86de201f35a09cf1a3e22b142e8e06cb678 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-01-01  Dmitry V. Levin  <ldv@altlinux.org>
+
+       * elf/dl-load.c (decompose_rpath): Check for rpath emptiness before
+       making a copy of it.
+
 2018-01-01  Joseph Myers  <joseph@codesourcery.com>
 
        * manual/texinfo.tex: Update to version 2017-12-26.21 with
index d9ec49d15e7d595297fe083899ca2d2daf0b0857..7554a99b5acb153762ab8967f330309ba9c69821 100644 (file)
@@ -499,7 +499,6 @@ decompose_rpath (struct r_search_path_struct *sps,
 {
   /* Make a copy we can work with.  */
   const char *where = l->l_name;
-  char *copy;
   char *cp;
   struct r_search_path_elem **result;
   size_t nelems;
@@ -538,22 +537,21 @@ decompose_rpath (struct r_search_path_struct *sps,
       while (*inhp != '\0');
     }
 
+  /* Ignore empty rpaths.  */
+  if (*rpath == '\0')
+    {
+      sps->dirs = (struct r_search_path_elem **) -1;
+      return false;
+    }
+
   /* Make a writable copy.  */
-  copy = __strdup (rpath);
+  char *copy = __strdup (rpath);
   if (copy == NULL)
     {
       errstring = N_("cannot create RUNPATH/RPATH copy");
       goto signal_error;
     }
 
-  /* Ignore empty rpaths.  */
-  if (*copy == 0)
-    {
-      free (copy);
-      sps->dirs = (struct r_search_path_elem **) -1;
-      return false;
-    }
-
   /* Count the number of necessary elements in the result array.  */
   nelems = 0;
   for (cp = copy; *cp != '\0'; ++cp)