diff options
author | Robert Chiras <robert.chiras@intel.com> | 2016-05-19 17:13:20 +0300 |
---|---|---|
committer | Jeremiah Senkpiel <fishrock123@rocketmail.com> | 2016-07-19 13:27:30 +0200 |
commit | 765de1ae114375648b87da8c27ca1cbd59bbe5ea (patch) | |
tree | b190ca5edb9bac8a1a98fda5892565a45feea796 /test/sequential/test-child-process-execsync.js | |
parent | 257a866918249935c7d4393dcb8d8fc6e4ad684a (diff) | |
download | android-node-v8-765de1ae114375648b87da8c27ca1cbd59bbe5ea.tar.gz android-node-v8-765de1ae114375648b87da8c27ca1cbd59bbe5ea.tar.bz2 android-node-v8-765de1ae114375648b87da8c27ca1cbd59bbe5ea.zip |
child_process: Check stderr before accessing it
If something bad happens in spawnSync, stderr might be null. Therefore,
we have to check it before using it, so we won't mask the actual
exception.
PR-URL: https://github.com/nodejs/node/pull/6877
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Robert Jefe Lindstädt <robert.lindstaedt@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'test/sequential/test-child-process-execsync.js')
-rw-r--r-- | test/sequential/test-child-process-execsync.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/sequential/test-child-process-execsync.js b/test/sequential/test-child-process-execsync.js index fc3c0494dc..e16fa32a40 100644 --- a/test/sequential/test-child-process-execsync.js +++ b/test/sequential/test-child-process-execsync.js @@ -12,6 +12,18 @@ var start = Date.now(); var err; var caught = false; +// Verify that stderr is not accessed when a bad shell is used +assert.throws( + function() { execSync('exit -1', {shell: 'bad_shell'}); }, + /spawnSync bad_shell ENOENT/, + 'execSync did not throw the expected exception!' +); +assert.throws( + function() { execFileSync('exit -1', {shell: 'bad_shell'}); }, + /spawnSync bad_shell ENOENT/, + 'execFileSync did not throw the expected exception!' +); + try { var cmd = `"${process.execPath}" -e "setTimeout(function(){}, ${SLEEP});"`; var ret = execSync(cmd, {timeout: TIMER}); |