about summary refs log tree commit diff
path: root/elf/rtld.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-11-06 00:16:32 +0000
committerUlrich Drepper <drepper@redhat.com>2001-11-06 00:16:32 +0000
commitc95f3fd42ed8d7660e817cf74b0883d7563d8102 (patch)
tree1395eae94b48080a50cbefa142906ce445fdae7f /elf/rtld.c
parentea41b9267dbd64faec6630e45fac87afb663ec11 (diff)
downloadglibc-c95f3fd42ed8d7660e817cf74b0883d7563d8102.tar.gz
glibc-c95f3fd42ed8d7660e817cf74b0883d7563d8102.tar.xz
glibc-c95f3fd42ed8d7660e817cf74b0883d7563d8102.zip
Update.
	* elf/elf.h: Add dynamic tag definitions for prelinking.

	* elf/rtld.c (process_envvars): Avoid using array of string pointers.
	Rewrite code to remove environment varables for SUID binaries.
	Small optimization in LD_PROFILE handling.
	* sysdeps/generic/unsecvars.h: Adjust format for process_envvars
	changes.
	* sysdeps/unix/sysv/linux/i386/dl-librecon.h: Likewise.

	* sysdeps/generic/dl-sysdep.c: Don't initialize _dl_cpuclock_offset.
Diffstat (limited to 'elf/rtld.c')
-rw-r--r--elf/rtld.c41
1 files changed, 14 insertions, 27 deletions
diff --git a/elf/rtld.c b/elf/rtld.c
index 47ac3e3cb6..e7d1e834b6 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -1345,7 +1345,7 @@ process_envvars (enum mode *modep)
 	    }
 
 	  /* Which shared object shall be profiled.  */
-	  if (memcmp (envline, "PROFILE", 7) == 0)
+	  if (memcmp (envline, "PROFILE", 7) == 0 && envline[8] != '\0')
 	    _dl_profile = &envline[8];
 	  break;
 
@@ -1430,38 +1430,27 @@ process_envvars (enum mode *modep)
      variables.  */
   if (__builtin_expect (__libc_enable_secure, 0))
     {
-      static const char *unsecure_envvars[] =
-      {
-	UNSECURE_ENVVARS,
+      static const char unsecure_envvars[] =
 #ifdef EXTRA_UNSECURE_ENVVARS
 	EXTRA_UNSECURE_ENVVARS
 #endif
-      };
-      size_t cnt;
-
-      if (preloadlist != NULL)
-	unsetenv ("LD_PRELOAD");
-      if (library_path != NULL)
-	unsetenv ("LD_LIBRARY_PATH");
-      if (_dl_origin_path != NULL)
-	unsetenv ("LD_ORIGIN_PATH");
-      if (debug_output != NULL)
-	unsetenv ("LD_DEBUG_OUTPUT");
-      if (_dl_profile != NULL)
-	unsetenv ("LD_PROFILE");
-
-      for (cnt = 0;
-	   cnt < sizeof (unsecure_envvars) / sizeof (unsecure_envvars[0]);
-	   ++cnt)
-	unsetenv (unsecure_envvars[cnt]);
+	UNSECURE_ENVVARS;
+      const char *nextp;
+
+      nextp = unsecure_envvars;
+      do
+	{
+	  unsetenv (nextp);
+	  nextp = (char *) rawmemchr (nextp, '\0') + 1;
+	}
+      while (*nextp != '\0');
 
       if (__access ("/etc/suid-debug", F_OK) != 0)
 	unsetenv ("MALLOC_CHECK_");
     }
 
-  /* The name of the object to profile cannot be empty.  */
-  if (_dl_profile != NULL && *_dl_profile == '\0')
-    _dl_profile = NULL;
+  /* The caller wants this information.  */
+  *modep = mode;
 
   /* If we have to run the dynamic linker in debugging mode and the
      LD_DEBUG_OUTPUT environment variable is given, we write the debug
@@ -1487,8 +1476,6 @@ process_envvars (enum mode *modep)
 	/* We use standard output if opening the file failed.  */
 	_dl_debug_fd = STDOUT_FILENO;
     }
-
-  *modep = mode;
 }