-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: fix OOB reads in process.title getter
The getter passed a stack-allocated, fixed-size buffer to uv_get_process_title() but neglected to check the return value. When the total length of the command line arguments exceeds the size of the buffer, libuv returns UV_ENOBUFS and doesn't modify the contents of the buffer. The getter then proceeded to return whatever garbage was on the stack at the time of the call, quite possibly reading beyond the end of the buffer. Add a GetProcessTitle() helper that reads the process title into a dynamically allocated buffer that is resized when necessary. Fixes: #31631 PR-URL: #31633 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Rich Trott <[email protected]>
- Loading branch information
1 parent
77ec381
commit 8964077
Showing
5 changed files
with
55 additions
and
10 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
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,22 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const { spawnSync } = require('child_process'); | ||
const { strictEqual } = require('assert'); | ||
|
||
// FIXME add sunos support | ||
if (common.isSunOS) | ||
common.skip(`Unsupported platform [${process.platform}]`); | ||
// FIXME add IBMi support | ||
if (common.isIBMi) | ||
common.skip('Unsupported platform IBMi'); | ||
|
||
// Explicitly assigning to process.title before starting the child process | ||
// is necessary otherwise *its* process.title is whatever the last | ||
// SetConsoleTitle() call in our process tree set it to. | ||
// Can be removed when https://github.com/libuv/libuv/issues/2667 is fixed. | ||
if (common.isWindows) | ||
process.title = process.execPath; | ||
|
||
const xs = 'x'.repeat(1024); | ||
const proc = spawnSync(process.execPath, ['-p', 'process.title', xs]); | ||
strictEqual(proc.stdout.toString().trim(), process.execPath); |