summaryrefslogtreecommitdiffstats
path: root/linker
diff options
context:
space:
mode:
authorDmitriy Ivanov <dimitry@google.com>2015-04-28 13:34:16 -0700
committerDmitriy Ivanov <dimitry@google.com>2015-04-28 14:43:58 -0700
commit62a0a63e072c97ba7650bb564d87ac6daf767558 (patch)
tree03306fea1bc0fb7ba4c526eb93d405a89b64b7c3 /linker
parent17b602c903c3199fad6353c43b0e6086c54bcce7 (diff)
downloadbionic-62a0a63e072c97ba7650bb564d87ac6daf767558.zip
bionic-62a0a63e072c97ba7650bb564d87ac6daf767558.tar.gz
bionic-62a0a63e072c97ba7650bb564d87ac6daf767558.tar.bz2
linker: use libc's environ variable to store envp
This is to make getenv() work correctly. Bug: http://b/20567629 (cherry picked from commit a85bcc2e99739420b5b4f9a5c337af1d26ac652b) Change-Id: I7c2289279b331793335029dc17a792d416efff4b
Diffstat (limited to 'linker')
-rw-r--r--linker/linker_environ.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/linker/linker_environ.cpp b/linker/linker_environ.cpp
index 9a0f009..3c466a2 100644
--- a/linker/linker_environ.cpp
+++ b/linker/linker_environ.cpp
@@ -36,7 +36,6 @@
#include "private/KernelArgumentBlock.h"
-static char** _envp;
static bool _AT_SECURE_value = true;
bool get_AT_SECURE() {
@@ -150,8 +149,8 @@ static bool __is_unsafe_environment_variable(const char* name) {
}
static void __sanitize_environment_variables() {
- char** src = _envp;
- char** dst = _envp;
+ char** src = environ;
+ char** dst = environ;
for (; src[0] != nullptr; ++src) {
if (!__is_valid_environment_variable(src[0])) {
continue;
@@ -168,7 +167,7 @@ static void __sanitize_environment_variables() {
void linker_env_init(KernelArgumentBlock& args) {
// Store environment pointer - can't be null.
- _envp = args.envp;
+ environ = args.envp;
__init_AT_SECURE(args);
__sanitize_environment_variables();
@@ -179,7 +178,7 @@ const char* linker_env_get(const char* name) {
return nullptr;
}
- for (char** p = _envp; p[0] != nullptr; ++p) {
+ for (char** p = environ; p[0] != nullptr; ++p) {
const char* val = env_match(p[0], name);
if (val != nullptr) {
if (val[0] == '\0') {