GeezerVison is showing github.com — child_process: fix handling of incorrect uid/gid in spawn · nodejs/node@180bb0b
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/child_process.js +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -37,7 +37,7 @@ const { | 37 | 37 | ERR_INVALID_OPT_VALUE, | 38 | 38 | ERR_OUT_OF_RANGE | 39 | 39 | } = require('internal/errors').codes; | 40 | | -const { validateString } = require('internal/validators'); | | 40 | +const { validateString, isInt32 } = require('internal/validators'); | 41 | 41 | const child_process = require('internal/child_process'); | 42 | 42 | const { | 43 | 43 | _validateStdio, | @@ -425,13 +425,13 @@ function normalizeSpawnArguments(file, args, options) { | 425 | 425 | } | 426 | 426 |
| 427 | 427 | // Validate the uid, if present. | 428 | | - if (options.uid != null && !Number.isInteger(options.uid)) { | 429 | | - throw new ERR_INVALID_ARG_TYPE('options.uid', 'integer', options.uid); | | 428 | + if (options.uid != null && !isInt32(options.uid)) { | | 429 | + throw new ERR_INVALID_ARG_TYPE('options.uid', 'int32', options.uid); | 430 | 430 | } | 431 | 431 |
| 432 | 432 | // Validate the gid, if present. | 433 | | - if (options.gid != null && !Number.isInteger(options.gid)) { | 434 | | - throw new ERR_INVALID_ARG_TYPE('options.gid', 'integer', options.gid); | | 433 | + if (options.gid != null && !isInt32(options.gid)) { | | 434 | + throw new ERR_INVALID_ARG_TYPE('options.gid', 'int32', options.gid); | 435 | 435 | } | 436 | 436 |
| 437 | 437 | // Validate the shell, if present. | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-child-process-spawn-typeerror.js +9-1Lines changed: 9 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -33,7 +33,7 @@ const invalidArgValueError = | 33 | 33 | common.expectsError({ code: 'ERR_INVALID_ARG_VALUE', type: TypeError }, 14); | 34 | 34 |
| 35 | 35 | const invalidArgTypeError = | 36 | | - common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }, 10); | | 36 | + common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }, 12); | 37 | 37 |
| 38 | 38 | assert.throws(function() { | 39 | 39 | const child = spawn(invalidcmd, 'this is not an array'); | @@ -76,6 +76,14 @@ assert.throws(function() { | 76 | 76 | spawn(cmd, [], 1); | 77 | 77 | }, invalidArgTypeError); | 78 | 78 |
| | 79 | +assert.throws(function() { | | 80 | + spawn(cmd, [], { uid: 2 ** 63 }); | | 81 | +}, invalidArgTypeError); | | 82 | + | | 83 | +assert.throws(function() { | | 84 | + spawn(cmd, [], { gid: 2 ** 63 }); | | 85 | +}, invalidArgTypeError); | | 86 | + | 79 | 87 | // Argument types for combinatorics. | 80 | 88 | const a = []; | 81 | 89 | const o = {}; | |
|