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 — child_process: fix handling of incorrect uid/gid in spawn · nodejs/node@180bb0b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • child_process.js
  • test/parallel
    • test-child-process-spawn-typeerror.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/child_process.js‎

Copy file name to clipboardExpand all lines: lib/child_process.js
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const {
3737
ERR_INVALID_OPT_VALUE,
3838
ERR_OUT_OF_RANGE
3939
} = require('internal/errors').codes;
40-
const { validateString } = require('internal/validators');
40+
const { validateString, isInt32 } = require('internal/validators');
4141
const child_process = require('internal/child_process');
4242
const {
4343
_validateStdio,
@@ -425,13 +425,13 @@ function normalizeSpawnArguments(file, args, options) {
425425
}
426426

427427
// 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);
430430
}
431431

432432
// 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);
435435
}
436436

437437
// Validate the shell, if present.
Collapse file

‎test/parallel/test-child-process-spawn-typeerror.js‎

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 numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const invalidArgValueError =
3333
common.expectsError({ code: 'ERR_INVALID_ARG_VALUE', type: TypeError }, 14);
3434

3535
const invalidArgTypeError =
36-
common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }, 10);
36+
common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }, 12);
3737

3838
assert.throws(function() {
3939
const child = spawn(invalidcmd, 'this is not an array');
@@ -76,6 +76,14 @@ assert.throws(function() {
7676
spawn(cmd, [], 1);
7777
}, invalidArgTypeError);
7878

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+
7987
// Argument types for combinatorics.
8088
const a = [];
8189
const o = {};

0 commit comments

Comments
0 (0)
You are visitor 01402775 — 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.