This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] elf: remove redundant code from _dl_dst_substitute


There are just two users of _dl_dst_substitute: one is expand_dst that
sets is_path argument to 0, another one is expand_dynamic_string_token.
The latter function also has just two users: one is _dl_map_object that
sets is_path argument to 0, another one is fillin_rpath that sets
is_path argument to 1 and name argument contains no ':'.

In any case (is_path && *name == ':') is always false and all code
depending on it can be safely removed.

* elf/dl-load.c (_dl_dst_substitute): Remove (is_path && *name == ':')
checks and all dependent code.
---
 ChangeLog     |  5 +++++
 elf/dl-load.c | 25 +++++--------------------
 2 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/elf/dl-load.c b/elf/dl-load.c
index 2964464..1601b33 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -247,6 +247,10 @@ _dl_dst_count (const char *name, int is_path)
 }
 
 
+/* _dl_dst_substitute is called either from expand_dst with is_path == 0
+   or from expand_dynamic_string_token.
+   The latter function is called either from _dl_map_object with is_path == 0
+   or from fillin_rpath with is_path == 1 and name containing no ':'.  */
 char *
 _dl_dst_substitute (struct link_map *l, const char *name, char *result,
 		    int is_path)
@@ -291,13 +295,7 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result,
 	      /* We cannot use this path element, the value of the
 		 replacement is unknown.  */
 	      wp = last_elem;
-	      name += len;
-	      while (*name != '\0' && (!is_path || *name != ':'))
-		++name;
-	      /* Also skip following colon if this is the first rpath
-		 element, but keep an empty element at the end.  */
-	      if (wp == result && is_path && *name == ':' && name[1] != '\0')
-		++name;
+	      break;
 	    }
 	  else
 	    /* No DST we recognize.  */
@@ -306,19 +304,6 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result,
       else
 	{
 	  *wp++ = *name++;
-	  if (is_path && *name == ':')
-	    {
-	      /* In SUID/SGID programs, after $ORIGIN expansion the
-		 normalized path must be rooted in one of the trusted
-		 directories.  */
-	      if (__glibc_unlikely (check_for_trusted)
-		  && !is_trusted_path_normalize (last_elem, wp - last_elem))
-		wp = last_elem;
-	      else
-		last_elem = wp;
-
-	      check_for_trusted = false;
-	    }
 	}
     }
   while (*name != '\0');
-- 
ldv


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]