From: Todd C. Miller Date: Wed, 22 Apr 2015 19:38:02 +0000 (-0600) Subject: Don't use dlsym() to find the libc getenv() since this may allocate X-Git-Tag: SUDO_1_8_14^2~157 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3715ab57dd63f81130ab19b3908a3240db696ef3;p=sudo 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). --- diff --git a/src/env_hooks.c b/src/env_hooks.c index fd1e37848..e4803507b 100644 --- a/src/env_hooks.c +++ b/src/env_hooks.c @@ -45,8 +45,13 @@ 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) {