GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — process: fix uid/gid validation to avoid crash · nodejs/node@803fbfb

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/bootstrap/switches
    • does_own_process_state.js
  • test/parallel
    • test-process-uid-gid.js
Expand file treeCollapse file tree
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
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function wrapPosixCredentialSetters(credentials) {
7676
function wrapIdSetter(type, method) {
7777
return function(id) {
7878
validateId(id, 'id');
79-
if (typeof id === 'number') id |= 0;
79+
if (typeof id === 'number') id >>>= 0;
8080
// Result is 0 on success, 1 if credential is unknown.
8181
const result = method(id);
8282
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
+7-11Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,13 @@ assert.throws(() => {
5353

5454
// Passing -0 shouldn't crash the process
5555
// Refs: https://github.com/nodejs/node/issues/32750
56-
try { process.setuid(-0); } catch {
57-
// Continue regardless of error.
58-
}
59-
try { process.seteuid(-0); } catch {
60-
// Continue regardless of error.
61-
}
62-
try { process.setgid(-0); } catch {
63-
// Continue regardless of error.
64-
}
65-
try { process.setegid(-0); } catch {
66-
// Continue regardless of error.
56+
// And neither should values exceeding 2 ** 31 - 1.
57+
for (const id of [-0, 2 ** 31, 2 ** 32 - 1]) {
58+
for (const fn of [process.setuid, process.setuid, process.setgid, process.setegid]) {
59+
try { fn(id); } catch {
60+
// Continue regardless of error.
61+
}
62+
}
6763
}
6864

6965
// If we're not running as super user...

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.