Browse Source

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: c67207731f/lib/child_process.js (L76)
v6
Rich Trott 8 years ago
parent
commit
df69d95b76
  1. 11
      test/parallel/test-cli-eval.js

11
test/parallel/test-cli-eval.js

@ -143,6 +143,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.

Loading…
Cancel
Save