Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/internal/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function parseFileMode(value, name, def) {
}

if (isUint32(value)) {
return value;
return 0xFFFFFFFF & value;
}

if (typeof value === 'number') {
Expand Down
3 changes: 3 additions & 0 deletions test/parallel/test-fs-read-stream-throw-type-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,6 @@ const NOT_SAFE_INTEGER = 2 ** 53;
].forEach((opts) =>
createReadStreamErr(example, opts, rangeError)
);

// Case 8: Should not throw any error even if mode is a huge unsigned int32
fs.createReadStream(example, { mode: 2176057344 });
16 changes: 16 additions & 0 deletions test/parallel/test-fs-write-stream-huge-unsigned-int-mode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';
require('../common');

// This test ensures that createWriteStream does not crash when the
// passed mode is a huge unsigned int32, as reported here:
// https://github.com/nodejs/node/issues/37430

const fs = require('fs');
const path = require('path');

const tmpdir = require('../common/tmpdir');
tmpdir.refresh();

const example = path.join(tmpdir.path, 'dummy');

fs.createWriteStream(example, { mode: 2176057344 });