Browse Source

Don't allow child process to clobber environ

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
d5ee777af2
  1. 7
      src/node_child_process.cc

7
src/node_child_process.cc

@ -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…
Cancel
Save