From 304ac910194fa89b49ebf5bed11a575079f443b4 Mon Sep 17 00:00:00 2001 From: Howard Hellyer Date: Thu, 5 Jan 2017 14:15:20 +0000 Subject: [PATCH] src: do not modify original argv array on AIX 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: https://github.com/nodejs/node/issues/10607 --- src/node_main.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/node_main.cc b/src/node_main.cc index 16bda81ae640..773d11f8b01a 100644 --- a/src/node_main.cc +++ b/src/node_main.cc @@ -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