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)
This commit is contained in:
parent
2e74b0da8f
commit
df69d95b76
@ -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…
x
Reference in New Issue
Block a user