Skip to content

Commit df69d95

Browse files
committed
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: #11800 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Refs: https://github.com/nodejs/node/blob/c67207731f16a78f6cae90e49c53b10728241ecf/lib/child_process.js#L76
1 parent 2e74b0d commit df69d95

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/parallel/test-cli-eval.js

+11
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,17 @@ child.exec(`${nodejs} --use-strict -p process.execArgv`,
143143
assert.strictEqual(stdout, '');
144144
assert.strictEqual(stderr, '');
145145
}));
146+
147+
// Make sure that monkey-patching process.execArgv doesn't cause child_process
148+
// to incorrectly munge execArgv.
149+
child.exec(
150+
`${nodejs} -e "process.execArgv = ['-e', 'console.log(42)', 'thirdArg'];` +
151+
`require('child_process').fork('${emptyFile}')"`,
152+
common.mustCall((err, stdout, stderr) => {
153+
assert.ifError(err);
154+
assert.strictEqual(stdout, '42\n');
155+
assert.strictEqual(stderr, '');
156+
}));
146157
}
147158

148159
// Regression test for https://github.com/nodejs/node/issues/8534.

0 commit comments

Comments
 (0)