| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9f2dd48 commit 803fbfb
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -76,7 +76,7 @@ function wrapPosixCredentialSetters(credentials) { | |||
| 76 | 76 | function wrapIdSetter(type, method) { | |
| 77 | 77 | return function(id) { | |
| 78 | 78 | validateId(id, 'id'); | |
| 79 | - if (typeof id === 'number') id |= 0; | ||
| 79 | + if (typeof id === 'number') id >>>= 0; | ||
| 80 | 80 | // Result is 0 on success, 1 if credential is unknown. | |
| 81 | 81 | const result = method(id); | |
| 82 | 82 | if (result === 1) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -53,17 +53,13 @@ assert.throws(() => { | |||
| 53 | 53 | ||
| 54 | 54 | // Passing -0 shouldn't crash the process | |
| 55 | 55 | // 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 | + } | ||
| 67 | 63 | } | |
| 68 | 64 | ||
| 69 | 65 | // If we're not running as super user... | |
| Back | FazBrowse Home | New Git URL |
0 commit comments