Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4cb4803

Browse filesBrowse files
TrottMylesBorins
authored andcommitted
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 <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
1 parent 2ee2cc6 commit 4cb4803
Copy full SHA for 4cb4803

File tree

Expand file treeCollapse file tree

1 file changed

+11
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-0
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-cli-eval.js
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,17 @@ child.exec(`${nodejs} --use-strict -p process.execArgv`,
117117
assert.strictEqual(stdout, '');
118118
assert.strictEqual(stderr, '');
119119
}));
120+
121+
// Make sure that monkey-patching process.execArgv doesn't cause child_process
122+
// to incorrectly munge execArgv.
123+
child.exec(
124+
`${nodejs} -e "process.execArgv = ['-e', 'console.log(42)', 'thirdArg'];` +
125+
`require('child_process').fork('${emptyFile}')"`,
126+
common.mustCall((err, stdout, stderr) => {
127+
assert.ifError(err);
128+
assert.strictEqual(stdout, '42\n');
129+
assert.strictEqual(stderr, '');
130+
}));
120131
}
121132

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.