aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2017-12-27 22:12:51 +0000
committerDmitry V. Levin <ldv@altlinux.org>2018-01-01 20:37:32 +0000
commitdbba87d531ad3ea372eba6cb56436a231ca7fb32 (patch)
treea202991877c50cd40a9a8ec0e71da5df5389b1e0 /elf
parent66ac23dec2373bc4188bc8801280545316a63267 (diff)
downloadglibc-dbba87d531ad3ea372eba6cb56436a231ca7fb32.zip
glibc-dbba87d531ad3ea372eba6cb56436a231ca7fb32.tar.gz
glibc-dbba87d531ad3ea372eba6cb56436a231ca7fb32.tar.bz2
elf: check for rpath emptiness before making a copy of it
* elf/dl-load.c (decompose_rpath): Check for rpath emptiness before making a copy of it.
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-load.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c
index d9ec49d..7554a99 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -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)