Skip to content

Commit

Permalink
test: add coverage for child_process bounds check
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Trott authored and MylesBorins committed Apr 19, 2017
1 parent 2ee2cc6 commit 4cb4803
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/parallel/test-cli-eval.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,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.
Expand Down

0 comments on commit 4cb4803

Please sign in to comment.