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 <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
  • Loading branch information
Trott authored and italoacasas committed Mar 20, 2017
1 parent 3ae58ac commit 8bda7b8
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 @@ -122,6 +122,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 8bda7b8

Please sign in to comment.