[sanitizer] Add char **GetEnviron() on all other platforms

Subscribers: kubamracek, llvm-commits

Differential Revision: https://reviews.llvm.org/D54165

llvm-svn: 346257
This commit is contained in:
Vitaly Buka 2018-11-06 19:23:12 +00:00
parent 1e209e284f
commit ecb2eb46bc
6 changed files with 21 additions and 3 deletions

View File

@ -224,6 +224,7 @@ u32 GetUid();
void ReExec();
void CheckASLR();
char **GetArgv();
char **GetEnviron();
void PrintCmdline();
bool StackSizeIsUnlimited();
uptr GetStackSizeLimitInBytes();

View File

@ -451,6 +451,7 @@ char **StoredArgv;
char **StoredEnviron;
char **GetArgv() { return StoredArgv; }
char **GetEnviron() { return StoredEnviron; }
const char *GetEnv(const char *name) {
if (StoredEnviron) {

View File

@ -623,8 +623,13 @@ char **GetArgv() {
return argv;
}
void ReExec() {
char **GetEnviron() {
char **argv, **envp;
GetArgsAndEnv(&argv, &envp);
return envp;
}
void ReExec() {
const char *pathname = "/proc/self/exe";
#if SANITIZER_NETBSD
@ -646,8 +651,7 @@ void ReExec() {
pathname = reinterpret_cast<const char *>(getauxval(AT_EXECFN));
#endif
GetArgsAndEnv(&argv, &envp);
uptr rv = internal_execve(pathname, argv, envp);
uptr rv = internal_execve(pathname, GetArgv(), GetEnviron());
int rverrno;
CHECK_EQ(internal_iserror(rv, &rverrno), true);
Printf("execve failed, errno %d\n", rverrno);

View File

@ -99,6 +99,12 @@ char **GetArgv() {
return argv;
}
char **GetEnviron() {
char **argv, **envp;
GetArgsAndEnv(&argv, &envp);
return envp;
}
void ReExec() {
UNIMPLEMENTED();
}

View File

@ -240,6 +240,7 @@ bool IsAccessibleMemoryRange(uptr beg, uptr size) {
}
char **GetArgv() { return nullptr; }
char **GetEnviron() { return nullptr; }
const char *GetEnv(const char *name) {
return getenv(name);

View File

@ -1021,6 +1021,11 @@ char **GetArgv() {
return 0;
}
char **GetEnviron() {
// FIXME: Actually implement this function.
return 0;
}
pid_t StartSubprocess(const char *program, const char *const argv[],
fd_t stdin_fd, fd_t stdout_fd, fd_t stderr_fd) {
// FIXME: implement on this platform