00db10
commit 97f13188c9fbafeaab89146996b3cce1f4952b5e
00db10
Author: Dmitry V. Levin <ldv@altlinux.org>
00db10
Date:   Tue Dec 19 21:06:23 2017 +0000
00db10
00db10
    elf: remove redundant code from _dl_dst_substitute
00db10
    
00db10
    There are just two users of _dl_dst_substitute: one is expand_dst that
00db10
    sets is_path argument to 0, another one is expand_dynamic_string_token.
00db10
    The latter function also has just two users: one is _dl_map_object that
00db10
    sets is_path argument to 0, another one is fillin_rpath that sets
00db10
    is_path argument to 1 and name argument contains no ':'.
00db10
    
00db10
    In any case (is_path && name[i] == ':') is always false and all code
00db10
    depending on it can be safely removed.
00db10
    
00db10
    * elf/dl-load.c (_dl_dst_substitute): Remove checks that is_path
00db10
    is set and name contains ':', and all code depending on these checks.
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
@@ -349,13 +349,7 @@ _dl_dst_substitute (struct link_map *l,
00db10
 	      /* We cannot use this path element, the value of the
00db10
 		 replacement is unknown.  */
00db10
 	      wp = last_elem;
00db10
-	      name += len;
00db10
-	      while (*name != '\0' && (!is_path || *name != ':'))
00db10
-		++name;
00db10
-	      /* Also skip following colon if this is the first rpath
00db10
-		 element, but keep an empty element at the end.  */
00db10
-	      if (wp == result && is_path && *name == ':' && name[1] != '\0')
00db10
-		++name;
00db10
+	      break;
00db10
 	    }
00db10
 	  else
00db10
 	    /* No DST we recognize.  */
00db10
@@ -364,19 +358,6 @@ _dl_dst_substitute (struct link_map *l,
00db10
       else
00db10
 	{
00db10
 	  *wp++ = *name++;
00db10
-	  if (is_path && *name == ':')
00db10
-	    {
00db10
-	      /* In SUID/SGID programs, after $ORIGIN expansion the
00db10
-		 normalized path must be rooted in one of the trusted
00db10
-		 directories.  */
00db10
-	      if (__builtin_expect (check_for_trusted, false)
00db10
-		  && !is_trusted_path_normalize (last_elem, wp - last_elem))
00db10
-		wp = last_elem;
00db10
-	      else
00db10
-		last_elem = wp;
00db10
-
00db10
-	      check_for_trusted = false;
00db10
-	    }
00db10
 	}
00db10
     }
00db10
   while (*name != '\0');