trace: use the cloned environment pointer
authorFelix Fietkau <nbd@nbd.name>
Mon, 5 Dec 2016 17:16:47 +0000 (18:16 +0100)
committerFelix Fietkau <nbd@nbd.name>
Mon, 5 Dec 2016 17:19:10 +0000 (18:19 +0100)
Fixes an issue where it would overwrite the first environment variable
with the preload one

Signed-off-by: Felix Fietkau <nbd@nbd.name>
trace/trace.c

index 662010e339ea224d04d9a5e701b1eeed5855934f..fdffaba5f7cdb9d1e25ef3161bdd818d9c248391 100644 (file)
@@ -187,9 +187,9 @@ int main(int argc, char **argv, char **envp)
 
                _envp = calloc(envc, sizeof(char *));
                memcpy(&_envp[1], _envp, envc * sizeof(char *));
-               *envp = preload;
+               *_envp = preload;
 
-               ret = execve(_argv[0], _argv, envp);
+               ret = execve(_argv[0], _argv, _envp);
                ERROR("failed to exec %s: %s\n", _argv[0], strerror(errno));
 
                free(_argv);