-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src,lib: handle invalid stdio configuration gracefully
Fixes an issue where malformed or unexpected stdio configurations could cause crashes or undefined behavior during child process spawning. This patch ensures robust validation of stdio entries: Fixes: #55932 Signed-off-by: Juan José Arboleda <[email protected]>
- Loading branch information
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('node:assert'); | ||
const { spawn } = require('node:child_process'); | ||
|
||
// The UNIX version of this test is enough. | ||
if (common.isWindows) { | ||
common.skip('This test is enough for Unix-like systems'); | ||
return; | ||
} | ||
|
||
// Refs: https://github.com/nodejs/node/issues/55932 | ||
Object.defineProperty(Array.prototype, '0', { | ||
set() { | ||
console.log(123); | ||
}, | ||
get() { | ||
return 123; | ||
} | ||
}, { configurable: true, writable: true }); | ||
|
||
const cp = spawn('ls'); | ||
|
||
// Can't use common.mustCall() here because array prototype is mutated. | ||
cp.on('error', (err) => { | ||
assert.strictEqual(err.code, 'EINVAL'); | ||
}); |