File tree 2 files changed +9
-0
lines changed
lib/internal/bootstrap/switches
2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ function wrapPosixCredentialSetters(credentials) {
80
80
function wrapIdSetter ( type , method ) {
81
81
return function ( id ) {
82
82
validateId ( id , 'id' ) ;
83
+ if ( typeof id === 'number' ) id |= 0 ;
83
84
// Result is 0 on success, 1 if credential is unknown.
84
85
const result = method ( id ) ;
85
86
if ( result === 1 ) {
Original file line number Diff line number Diff line change @@ -51,6 +51,13 @@ assert.throws(() => {
51
51
message : 'User identifier does not exist: fhqwhgadshgnsdhjsdbkhsdabkfabkveyb'
52
52
} ) ;
53
53
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
+
54
61
// If we're not running as super user...
55
62
if ( process . getuid ( ) !== 0 ) {
56
63
// Should not throw.
79
86
}
80
87
process . setgid ( 'nogroup' ) ;
81
88
}
89
+
82
90
const newgid = process . getgid ( ) ;
83
91
assert . notStrictEqual ( newgid , oldgid ) ;
84
92
You can’t perform that action at this time.
0 commit comments