diff options
author | millert <millert@openbsd.org> | 2019-12-11 18:27:54 +0000 |
---|---|---|
committer | millert <millert@openbsd.org> | 2019-12-11 18:27:54 +0000 |
commit | eee3c75f9abd5ea51e066dd0fe6b1efa470e4d0c (patch) | |
tree | cfc67850a7fcc1c39fb79ba06c6aa8e2f4672b23 /libexec/ld.so/loader.c | |
parent | Allow search across wrapped lines and fix some inconsistencies in how th (diff) | |
download | wireguard-openbsd-eee3c75f9abd5ea51e066dd0fe6b1efa470e4d0c.tar.xz wireguard-openbsd-eee3c75f9abd5ea51e066dd0fe6b1efa470e4d0c.zip |
ld.so may fail to remove the LD_LIBRARY_PATH environment variable for
set-user-ID and set-group-ID executables in low memory conditions.
Reported by Qualys
Diffstat (limited to 'libexec/ld.so/loader.c')
-rw-r--r-- | libexec/ld.so/loader.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libexec/ld.so/loader.c b/libexec/ld.so/loader.c index 7ed24131350..bf62da51bbe 100644 --- a/libexec/ld.so/loader.c +++ b/libexec/ld.so/loader.c @@ -1,4 +1,4 @@ -/* $OpenBSD: loader.c,v 1.188 2019/12/07 22:57:47 guenther Exp $ */ +/* $OpenBSD: loader.c,v 1.189 2019/12/11 18:27:54 millert Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -262,13 +262,14 @@ _dl_dopreload(char *paths) void _dl_setup_env(const char *argv0, char **envp) { + char *libpath; static char progname_storage[NAME_MAX+1] = ""; /* * Get paths to various things we are going to use. */ _dl_debug = _dl_getenv("LD_DEBUG", envp) != NULL; - _dl_libpath = _dl_split_path(_dl_getenv("LD_LIBRARY_PATH", envp)); + libpath = _dl_getenv("LD_LIBRARY_PATH", envp); _dl_preload = _dl_getenv("LD_PRELOAD", envp); _dl_bindnow = _dl_getenv("LD_BIND_NOW", envp) != NULL; _dl_traceld = _dl_getenv("LD_TRACE_LOADED_OBJECTS", envp) != NULL; @@ -282,9 +283,8 @@ _dl_setup_env(const char *argv0, char **envp) */ _dl_trust = !_dl_issetugid(); if (!_dl_trust) { /* Zap paths if s[ug]id... */ - if (_dl_libpath) { - _dl_free_path(_dl_libpath); - _dl_libpath = NULL; + if (libpath) { + libpath = NULL; _dl_unsetenv("LD_LIBRARY_PATH", envp); } if (_dl_preload) { @@ -300,6 +300,8 @@ _dl_setup_env(const char *argv0, char **envp) _dl_unsetenv("LD_DEBUG", envp); } } + if (libpath) + _dl_libpath = _dl_split_path(libpath); environ = envp; _dl_trace_setup(envp); |