|
|
147e83 |
commit 2a939a7e6d81f109d49306bc2e10b4ac9ceed8f9
|
|
|
147e83 |
Author: Ondřej Bílka <neleai@seznam.cz>
|
|
|
147e83 |
Date: Mon Dec 2 14:53:14 2013 +0100
|
|
|
147e83 |
|
|
|
147e83 |
Return fixed version of breaking of RPATH when $ORIGIN contains colons
|
|
|
147e83 |
|
|
|
147e83 |
Index: glibc-2.17-c758a686/elf/dl-load.c
|
|
|
147e83 |
===================================================================
|
|
|
147e83 |
--- glibc-2.17-c758a686.orig/elf/dl-load.c
|
|
|
147e83 |
+++ glibc-2.17-c758a686/elf/dl-load.c
|
|
|
147e83 |
@@ -487,14 +487,19 @@ static size_t max_dirnamelen;
|
|
|
147e83 |
|
|
|
147e83 |
static struct r_search_path_elem **
|
|
|
147e83 |
fillin_rpath (char *rpath, struct r_search_path_elem **result, const char *sep,
|
|
|
147e83 |
- int check_trusted, const char *what, const char *where)
|
|
|
147e83 |
+ int check_trusted, const char *what, const char *where,
|
|
|
147e83 |
+ struct link_map *l)
|
|
|
147e83 |
{
|
|
|
147e83 |
char *cp;
|
|
|
147e83 |
size_t nelems = 0;
|
|
|
147e83 |
+ char *to_free;
|
|
|
147e83 |
|
|
|
147e83 |
while ((cp = __strsep (&rpath, sep)) != NULL)
|
|
|
147e83 |
{
|
|
|
147e83 |
struct r_search_path_elem *dirp;
|
|
|
147e83 |
+
|
|
|
147e83 |
+ to_free = cp = expand_dynamic_string_token (l, cp, 1);
|
|
|
147e83 |
+
|
|
|
147e83 |
size_t len = strlen (cp);
|
|
|
147e83 |
|
|
|
147e83 |
/* `strsep' can pass an empty string. This has to be
|
|
|
147e83 |
@@ -515,7 +520,10 @@ fillin_rpath (char *rpath, struct r_sear
|
|
|
147e83 |
|
|
|
147e83 |
/* Make sure we don't use untrusted directories if we run SUID. */
|
|
|
147e83 |
if (__builtin_expect (check_trusted, 0) && !is_trusted_path (cp, len))
|
|
|
147e83 |
- continue;
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ free (to_free);
|
|
|
147e83 |
+ continue;
|
|
|
147e83 |
+ }
|
|
|
147e83 |
|
|
|
147e83 |
/* See if this directory is already known. */
|
|
|
147e83 |
for (dirp = GL(dl_all_dirs); dirp != NULL; dirp = dirp->next)
|
|
|
147e83 |
@@ -576,6 +584,7 @@ fillin_rpath (char *rpath, struct r_sear
|
|
|
147e83 |
/* Put it in the result array. */
|
|
|
147e83 |
result[nelems++] = dirp;
|
|
|
147e83 |
}
|
|
|
147e83 |
+ free (to_free);
|
|
|
147e83 |
}
|
|
|
147e83 |
|
|
|
147e83 |
/* Terminate the array. */
|
|
|
147e83 |
@@ -631,9 +640,8 @@ decompose_rpath (struct r_search_path_st
|
|
|
147e83 |
while (*inhp != '\0');
|
|
|
147e83 |
}
|
|
|
147e83 |
|
|
|
147e83 |
- /* Make a writable copy. At the same time expand possible dynamic
|
|
|
147e83 |
- string tokens. */
|
|
|
147e83 |
- copy = expand_dynamic_string_token (l, rpath, 1);
|
|
|
147e83 |
+ /* Make a writable copy. */
|
|
|
147e83 |
+ copy = local_strdup (rpath);
|
|
|
147e83 |
if (copy == NULL)
|
|
|
147e83 |
{
|
|
|
147e83 |
errstring = N_("cannot create RUNPATH/RPATH copy");
|
|
|
147e83 |
@@ -666,7 +674,7 @@ decompose_rpath (struct r_search_path_st
|
|
|
147e83 |
_dl_signal_error (ENOMEM, NULL, NULL, errstring);
|
|
|
147e83 |
}
|
|
|
147e83 |
|
|
|
147e83 |
- fillin_rpath (copy, result, ":", 0, what, where);
|
|
|
147e83 |
+ fillin_rpath (copy, result, ":", 0, what, where, l);
|
|
|
147e83 |
|
|
|
147e83 |
/* Free the copied RPATH string. `fillin_rpath' make own copies if
|
|
|
147e83 |
necessary. */
|
|
|
147e83 |
@@ -714,9 +722,7 @@ _dl_init_paths (const char *llp)
|
|
|
147e83 |
const char *strp;
|
|
|
147e83 |
struct r_search_path_elem *pelem, **aelem;
|
|
|
147e83 |
size_t round_size;
|
|
|
147e83 |
-#ifdef SHARED
|
|
|
147e83 |
- struct link_map *l;
|
|
|
147e83 |
-#endif
|
|
|
147e83 |
+ struct link_map __attribute__ ((unused)) *l = NULL;
|
|
|
147e83 |
/* Initialize to please the compiler. */
|
|
|
147e83 |
const char *errstring = NULL;
|
|
|
147e83 |
|
|
|
147e83 |
@@ -865,7 +871,7 @@ _dl_init_paths (const char *llp)
|
|
|
147e83 |
|
|
|
147e83 |
(void) fillin_rpath (llp_tmp, env_path_list.dirs, ":;",
|
|
|
147e83 |
INTUSE(__libc_enable_secure), "LD_LIBRARY_PATH",
|
|
|
147e83 |
- NULL);
|
|
|
147e83 |
+ NULL, l);
|
|
|
147e83 |
|
|
|
147e83 |
if (env_path_list.dirs[0] == NULL)
|
|
|
147e83 |
{
|