diff options
author | Rich Trott <rtrott@gmail.com> | 2017-03-11 09:40:06 +0300 |
---|---|---|
committer | Italo A. Casas <me@italoacasas.com> | 2017-03-20 17:38:06 +0300 |
commit | 8bda7b8d39b85c77c53f510beadd6e4d898890ad (patch) | |
tree | ef655542909a250051f0244c8f907a70a93e4019 /test | |
parent | 3ae58acd29fcbde16206f238a2a4cc935892b2de (diff) |
test: add coverage for child_process bounds check
Make sure that monkey-patching process.execArgv doesn't cause
child_process to incorrectly munge execArgv in fork().
This basically is adding coverage for an `index > 0` check (see Refs).
Previously, that condition was never false in any of the tests.
PR-URL: https://github.com/nodejs/node/pull/11800
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Refs: https://github.com/nodejs/node/blob/c67207731f16a78f6cae90e49c53b10728241ecf/lib/child_process.js#L76
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-cli-eval.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/parallel/test-cli-eval.js b/test/parallel/test-cli-eval.js index 260acdb0d6f..9f781642a97 100644 --- a/test/parallel/test-cli-eval.js +++ b/test/parallel/test-cli-eval.js @@ -122,6 +122,17 @@ child.exec(`${nodejs} --use-strict -p process.execArgv`, assert.strictEqual(stdout, ''); assert.strictEqual(stderr, ''); })); + + // Make sure that monkey-patching process.execArgv doesn't cause child_process + // to incorrectly munge execArgv. + child.exec( + `${nodejs} -e "process.execArgv = ['-e', 'console.log(42)', 'thirdArg'];` + + `require('child_process').fork('${emptyFile}')"`, + common.mustCall((err, stdout, stderr) => { + assert.ifError(err); + assert.strictEqual(stdout, '42\n'); + assert.strictEqual(stderr, ''); + })); } // Regression test for https://github.com/nodejs/node/issues/8534. |