| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1a4d34e commit 94afc3e
2 files 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,6 +86,7 @@ try { | |||
| 79 | 86 | } | |
| 80 | 87 | process.setgid('nogroup'); | |
| 81 | 88 | } | |
| 89 | + | ||
| 82 | 90 | const newgid = process.getgid(); | |
| 83 | 91 | assert.notStrictEqual(newgid, oldgid); | |
| 84 | 92 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments