Skip to content

fs: fix handling of `struct stat` fields

Checklist
  • make -j4 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included (how? I’m open to suggestions.)
  • commit message follows commit guidelines
Affected core subsystem(s)

fs

Description of change

FChown and Chown test that the uid and gid parameters they receive are unsigned integers, but Stat() and FStat() would return the corresponding fields of struct stat as signed integers. Applications which pass those these values directly to Chown may fail (e.g. for nobody on OS X, who has an uid of -2, see e.g. https://github.com/nodejs/node-v0.x-archive/issues/5890).

This patch changes the Integer::New() call for uid and gid to Integer::NewFromUnsigned().

All other fields are kept as they are, for performance, but strictly speaking the respective sizes of those fields aren’t specified, either.

Ref: https://github.com/npm/npm/issues/13918

/cc @nodejs/fs

CI: https://ci.nodejs.org/job/node-test-commit/5026/

Merge request reports

Loading