mirror of https://github.com/nodejs/node.git
Don't allow child process to clobber environ
parent
d1500cee6e
commit
d5ee777af2
|
@ -302,6 +302,10 @@ int ChildProcess::Spawn(const char *file, char *const args[], char **env) {
|
|||
return -3;
|
||||
}
|
||||
|
||||
// Save environ in the case that we get it clobbered
|
||||
// by the child process.
|
||||
char **save_our_env = environ;
|
||||
|
||||
switch (pid_ = vfork()) {
|
||||
case -1: // Error.
|
||||
Shutdown();
|
||||
|
@ -324,6 +328,9 @@ int ChildProcess::Spawn(const char *file, char *const args[], char **env) {
|
|||
_exit(127);
|
||||
}
|
||||
|
||||
// Restore environment.
|
||||
environ = save_our_env;
|
||||
|
||||
// Parent.
|
||||
|
||||
ev_child_set(&child_watcher_, pid_, 0);
|
||||
|
|
Loading…
Reference in New Issue