]> granicus.if.org Git - sudo/commitdiff
Don't use dlsym() to find the libc getenv() since this may allocate
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 22 Apr 2015 19:38:02 +0000 (13:38 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 22 Apr 2015 19:38:02 +0000 (13:38 -0600)
memory on some systems (glibc) which leads to a hang if malloc()
calls getenv() (jemalloc).

src/env_hooks.c

index fd1e378480fdd3298934963e9939768a5b3c6023..e4803507b866ef4f7174511636c07f7cbb567b84 100644 (file)
 extern char **environ;         /* global environment pointer */
 static char **priv_environ;    /* private environment pointer */
 
-static char *
-rpl_getenv(const char *name)
+/*
+ * NOTE: we don't use dlsym() to find the libc getenv()
+ *      since this may allocate memory on some systems (glibc)
+ *      which leads to a hang if malloc() calls getenv (jemalloc).
+ */
+char *
+getenv_unhooked(const char *name)
 {
     char **ep, *val = NULL;
     size_t namelen = 0;
@@ -63,19 +68,6 @@ rpl_getenv(const char *name)
     return val;
 }
 
-typedef char * (*sudo_fn_getenv_t)(const char *);
-
-char *
-getenv_unhooked(const char *name)
-{
-    sudo_fn_getenv_t fn;
-
-    fn = (sudo_fn_getenv_t)sudo_dso_findsym(SUDO_DSO_NEXT, "getenv");
-    if (fn != NULL)
-       return fn(name);
-    return rpl_getenv(name);
-}
-
 __dso_public char *
 getenv(const char *name)
 {