Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 94afc3e

Browse filesBrowse files
jasnelldanielleadams
authored andcommitted
process: passing -1 to setuid/setgid should not abort
Fixes: #32750 Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #36786 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Harshitha K P <harshitha014@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
1 parent 1a4d34e commit 94afc3e
Copy full SHA for 94afc3e

File tree

Expand file treeCollapse file tree

2 files changed

+9
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-0
lines changed
Open diff view settings
Collapse file

‎lib/internal/bootstrap/switches/does_own_process_state.js‎

Copy file name to clipboardExpand all lines: lib/internal/bootstrap/switches/does_own_process_state.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ function wrapPosixCredentialSetters(credentials) {
8080
function wrapIdSetter(type, method) {
8181
return function(id) {
8282
validateId(id, 'id');
83+
if (typeof id === 'number') id |= 0;
8384
// Result is 0 on success, 1 if credential is unknown.
8485
const result = method(id);
8586
if (result === 1) {
Collapse file

‎test/parallel/test-process-uid-gid.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-process-uid-gid.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ assert.throws(() => {
5151
message: 'User identifier does not exist: fhqwhgadshgnsdhjsdbkhsdabkfabkveyb'
5252
});
5353

54+
// Passing -0 shouldn't crash the process
55+
// Refs: https://github.com/nodejs/node/issues/32750
56+
try { process.setuid(-0); } catch {}
57+
try { process.seteuid(-0); } catch {}
58+
try { process.setgid(-0); } catch {}
59+
try { process.setegid(-0); } catch {}
60+
5461
// If we're not running as super user...
5562
if (process.getuid() !== 0) {
5663
// Should not throw.
@@ -79,6 +86,7 @@ try {
7986
}
8087
process.setgid('nogroup');
8188
}
89+
8290
const newgid = process.getgid();
8391
assert.notStrictEqual(newgid, oldgid);
8492

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.