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