25845f
commit 2bd86632b7cb97dc9002a23795e140fc880e1987
25845f
Author: Dmitry V. Levin <ldv@altlinux.org>
25845f
Date:   Wed Dec 20 11:27:51 2017 +0000
25845f
25845f
    elf: remove redundant is_path argument
25845f
    
25845f
    is_path argument is no longer used and could be safely removed.
25845f
    
25845f
    * elf/dl-dst.h (DL_DST_COUNT): Remove is_path argument, all callers
25845f
    updated.
25845f
    * elf/dl-load.c (is_dst, _dl_dst_count, _dl_dst_substitute,
25845f
    expand_dynamic_string_token): Likewise.
25845f
    * sysdeps/generic/ldsodefs.h (_dl_dst_count, _dl_dst_substitute): Remove
25845f
    is_path argument.
25845f
25845f
Index: glibc-2.17-c758a686/elf/dl-deps.c
25845f
===================================================================
25845f
--- glibc-2.17-c758a686.orig/elf/dl-deps.c
25845f
+++ glibc-2.17-c758a686/elf/dl-deps.c
25845f
@@ -101,7 +101,7 @@ struct list
25845f
   ({									      \
25845f
     const char *__str = (str);						      \
25845f
     const char *__result = __str;					      \
25845f
-    size_t __dst_cnt = DL_DST_COUNT (__str, 0);				      \
25845f
+    size_t __dst_cnt = DL_DST_COUNT (__str);				      \
25845f
 									      \
25845f
     if (__dst_cnt != 0)							      \
25845f
       {									      \
25845f
@@ -115,7 +115,7 @@ DST not allowed in SUID/SGID programs"))
25845f
 	__newp = (char *) alloca (DL_DST_REQUIRED (l, __str, strlen (__str),  \
25845f
 						   __dst_cnt));		      \
25845f
 									      \
25845f
-	__result = _dl_dst_substitute (l, __str, __newp, 0);		      \
25845f
+	__result = _dl_dst_substitute (l, __str, __newp);		      \
25845f
 									      \
25845f
 	if (*__result == '\0')						      \
25845f
 	  {								      \
25845f
Index: glibc-2.17-c758a686/elf/dl-dst.h
25845f
===================================================================
25845f
--- glibc-2.17-c758a686.orig/elf/dl-dst.h
25845f
+++ glibc-2.17-c758a686/elf/dl-dst.h
25845f
@@ -20,13 +20,13 @@
25845f
 
25845f
 /* Determine the number of DST elements in the name.  Only if IS_PATH is
25845f
    nonzero paths are recognized (i.e., multiple, ':' separated filenames).  */
25845f
-#define DL_DST_COUNT(name, is_path) \
25845f
+#define DL_DST_COUNT(name) \
25845f
   ({									      \
25845f
     size_t __cnt = 0;							      \
25845f
     const char *__sf = strchr (name, '$');				      \
25845f
 									      \
25845f
     if (__builtin_expect (__sf != NULL, 0))				      \
25845f
-      __cnt = _dl_dst_count (__sf, is_path);			      \
25845f
+      __cnt = _dl_dst_count (__sf);					      \
25845f
 									      \
25845f
     __cnt; })
25845f
 
25845f
Index: glibc-2.17-c758a686/elf/dl-load.c
25845f
===================================================================
25845f
--- glibc-2.17-c758a686.orig/elf/dl-load.c
25845f
+++ glibc-2.17-c758a686/elf/dl-load.c
25845f
@@ -232,8 +232,7 @@ is_trusted_path_normalize (const char *p
25845f
 
25845f
 
25845f
 static size_t
25845f
-is_dst (const char *start, const char *name, const char *str,
25845f
-	int is_path, int secure)
25845f
+is_dst (const char *start, const char *name, const char *str, int secure)
25845f
 {
25845f
   size_t len;
25845f
   bool is_curly = false;
25845f
@@ -271,7 +270,7 @@ is_dst (const char *start, const char *n
25845f
 
25845f
 
25845f
 size_t
25845f
-_dl_dst_count (const char *name, int is_path)
25845f
+_dl_dst_count (const char *name)
25845f
 {
25845f
   const char *const start = name;
25845f
   size_t cnt = 0;
25845f
@@ -283,10 +282,9 @@ _dl_dst_count (const char *name, int is_
25845f
       /* $ORIGIN is not expanded for SUID/GUID programs (except if it
25845f
 	 is $ORIGIN alone) and it must always appear first in path.  */
25845f
       ++name;
25845f
-      if ((len = is_dst (start, name, "ORIGIN", is_path,
25845f
-			 INTUSE(__libc_enable_secure))) != 0
25845f
-	  || (len = is_dst (start, name, "PLATFORM", is_path, 0)) != 0
25845f
-	  || (len = is_dst (start, name, "LIB", is_path, 0)) != 0)
25845f
+      if ((len = is_dst (start, name, "ORIGIN", INTUSE(__libc_enable_secure))) != 0
25845f
+	  || (len = is_dst (start, name, "PLATFORM", 0)) != 0
25845f
+	  || (len = is_dst (start, name, "LIB", 0)) != 0)
25845f
 	++cnt;
25845f
 
25845f
       name = strchr (name + len, '$');
25845f
@@ -298,8 +296,7 @@ _dl_dst_count (const char *name, int is_
25845f
 
25845f
 
25845f
 char *
25845f
-_dl_dst_substitute (struct link_map *l, const char *name, char *result,
25845f
-		    int is_path)
25845f
+_dl_dst_substitute (struct link_map *l, const char *name, char *result)
25845f
 {
25845f
   const char *const start = name;
25845f
 
25845f
@@ -319,8 +316,7 @@ _dl_dst_substitute (struct link_map *l,
25845f
 	  size_t len;
25845f
 
25845f
 	  ++name;
25845f
-	  if ((len = is_dst (start, name, "ORIGIN", is_path,
25845f
-			     INTUSE(__libc_enable_secure))) != 0)
25845f
+	  if ((len = is_dst (start, name, "ORIGIN", INTUSE(__libc_enable_secure))) != 0)
25845f
 	    {
25845f
 #ifndef SHARED
25845f
 	      if (l == NULL)
25845f
@@ -332,9 +328,9 @@ _dl_dst_substitute (struct link_map *l,
25845f
 	      check_for_trusted = (INTUSE(__libc_enable_secure)
25845f
 				   && l->l_type == lt_executable);
25845f
 	    }
25845f
-	  else if ((len = is_dst (start, name, "PLATFORM", is_path, 0)) != 0)
25845f
+	  else if ((len = is_dst (start, name, "PLATFORM", 0)) != 0)
25845f
 	    repl = GLRO(dl_platform);
25845f
-	  else if ((len = is_dst (start, name, "LIB", is_path, 0)) != 0)
25845f
+	  else if ((len = is_dst (start, name, "LIB", 0)) != 0)
25845f
 	    repl = DL_DST_LIB;
25845f
 
25845f
 	  if (repl != NULL && repl != (const char *) -1)
25845f
@@ -378,7 +374,7 @@ _dl_dst_substitute (struct link_map *l,
25845f
    belonging to the map is loaded.  In this case the path element
25845f
    containing $ORIGIN is left out.  */
25845f
 static char *
25845f
-expand_dynamic_string_token (struct link_map *l, const char *s, int is_path)
25845f
+expand_dynamic_string_token (struct link_map *l, const char *s)
25845f
 {
25845f
   /* We make two runs over the string.  First we determine how large the
25845f
      resulting string is and then we copy it over.  Since this is no
25845f
@@ -389,7 +385,7 @@ expand_dynamic_string_token (struct link
25845f
   char *result;
25845f
 
25845f
   /* Determine the number of DST elements.  */
25845f
-  cnt = DL_DST_COUNT (s, is_path);
25845f
+  cnt = DL_DST_COUNT (s);
25845f
 
25845f
   /* If we do not have to replace anything simply copy the string.  */
25845f
   if (__builtin_expect (cnt, 0) == 0)
25845f
@@ -403,7 +399,7 @@ expand_dynamic_string_token (struct link
25845f
   if (result == NULL)
25845f
     return NULL;
25845f
 
25845f
-  return _dl_dst_substitute (l, s, result, is_path);
25845f
+  return _dl_dst_substitute (l, s, result);
25845f
 }
25845f
 
25845f
 
25845f
@@ -458,7 +454,7 @@ fillin_rpath (char *rpath, struct r_sear
25845f
     {
25845f
       struct r_search_path_elem *dirp;
25845f
 
25845f
-      to_free = cp = expand_dynamic_string_token (l, cp, 1);
25845f
+      to_free = cp = expand_dynamic_string_token (l, cp);
25845f
 
25845f
       size_t len = strlen (cp);
25845f
 
25845f
@@ -2263,7 +2259,7 @@ _dl_map_object (struct link_map *loader,
25845f
     {
25845f
       /* The path may contain dynamic string tokens.  */
25845f
       realname = (loader
25845f
-		  ? expand_dynamic_string_token (loader, name, 0)
25845f
+		  ? expand_dynamic_string_token (loader, name)
25845f
 		  : local_strdup (name));
25845f
       if (realname == NULL)
25845f
 	fd = -1;
25845f
Index: glibc-2.17-c758a686/sysdeps/generic/ldsodefs.h
25845f
===================================================================
25845f
--- glibc-2.17-c758a686.orig/sysdeps/generic/ldsodefs.h
25845f
+++ glibc-2.17-c758a686/sysdeps/generic/ldsodefs.h
25845f
@@ -983,11 +983,11 @@ extern void _dl_nothread_init_static_tls
25845f
 extern const char *_dl_get_origin (void) attribute_hidden;
25845f
 
25845f
 /* Count DSTs.  */
25845f
-extern size_t _dl_dst_count (const char *name, int is_path) attribute_hidden;
25845f
+extern size_t _dl_dst_count (const char *name) attribute_hidden;
25845f
 
25845f
 /* Substitute DST values.  */
25845f
 extern char *_dl_dst_substitute (struct link_map *l, const char *name,
25845f
-				 char *result, int is_path) attribute_hidden;
25845f
+				 char *result) attribute_hidden;
25845f
 
25845f
 /* Check validity of the caller.  */
25845f
 extern int _dl_check_caller (const void *caller, enum allowmask mask)