Skip to content

Commit

Permalink
src: do not modify original argv array on AIX
Browse files Browse the repository at this point in the history
AIX passes the same argv array that ps and other utilities see to
main(). Node removes elements from argv but as it can't pass back
updates to argc which is passed by value to main() it effectively
corrupts that array for other users.

Fixes: nodejs#10607
  • Loading branch information
hhellyer committed Jan 5, 2017
1 parent 0a93728 commit 304ac91
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/node_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ int main(int argc, char *argv[]) {
// calls elsewhere in the program (e.g., any logging from V8.)
setvbuf(stdout, nullptr, _IONBF, 0);
setvbuf(stderr, nullptr, _IONBF, 0);
#ifdef _AIX
// AIX passes the same argv array that ps and other utilities see.
// Node removes elements from argv but can't pass back updates to
// argc effectively corrupting it for other users.
char *local_argv[argc+1];
for (int i = 0; i < argc; i++) {
local_argv[i] = argv[i];
}
local_argv[argc] = nullptr;
return node::Start(argc, local_argv);
#else
return node::Start(argc, argv);
#endif // _AIX
}
#endif

0 comments on commit 304ac91

Please sign in to comment.