Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
mask mode with 0xFFFFFFFF
  • Loading branch information
RaisinTen committed Feb 18, 2021
commit 49132cc9b3dd7a268387b36a0b785d606de33b5d
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
4 changes: 2 additions & 2 deletions test/parallel/test-fs-read-stream-throw-type-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ const NOT_SAFE_INTEGER = 2 ** 53;
createReadStreamErr(example, opts, rangeError)
);

// Case 8: Should throw RangeError if mode is out of range
createReadStreamErr(example, { mode: 2176057344 }, 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 });
24 changes: 0 additions & 24 deletions test/parallel/test-fs-write-stream-throw-range-error.js

This file was deleted.