mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-23 09:07:18 +03:00
Ignore MALLOC_CONF in set{uid,gid,cap} binaries.
This eliminates the malloc tunables as tools for an attacker. Closes #173
This commit is contained in:
parent
e12eaf93dc
commit
b74041fb6e
3 changed files with 50 additions and 1 deletions
|
|
@ -648,6 +648,27 @@ stats_print_atexit(void)
|
|||
* Begin initialization functions.
|
||||
*/
|
||||
|
||||
#ifndef JEMALLOC_HAVE_SECURE_GETENV
|
||||
# ifdef JEMALLOC_HAVE_ISSETUGID
|
||||
static char *
|
||||
secure_getenv(const char *name)
|
||||
{
|
||||
|
||||
if (issetugid() == 0)
|
||||
return (getenv(name));
|
||||
else
|
||||
return (NULL);
|
||||
}
|
||||
# else
|
||||
static char *
|
||||
secure_getenv(const char *name)
|
||||
{
|
||||
|
||||
return (getenv(name));
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static unsigned
|
||||
malloc_ncpus(void)
|
||||
{
|
||||
|
|
@ -824,7 +845,7 @@ malloc_conf_init(void)
|
|||
#endif
|
||||
;
|
||||
|
||||
if ((opts = getenv(envname)) != NULL) {
|
||||
if ((opts = secure_getenv(envname)) != NULL) {
|
||||
/*
|
||||
* Do nothing; opts is already initialized to
|
||||
* the value of the MALLOC_CONF environment
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue