mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
74e0ca3f49
PR-URL: https://github.com/nodejs/node/pull/49125 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
40 lines
976 B
JavaScript
40 lines
976 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
tmpdir.refresh();
|
|
|
|
// fs.write with length > INT32_MAX
|
|
|
|
common.skipIf32Bits();
|
|
|
|
let buf;
|
|
try {
|
|
buf = Buffer.allocUnsafe(0x7FFFFFFF + 1);
|
|
} catch (e) {
|
|
// If the exception is not due to memory confinement then rethrow it.
|
|
if (e.message !== 'Array buffer allocation failed') throw (e);
|
|
common.skip('skipped due to memory requirements');
|
|
}
|
|
|
|
const filename = tmpdir.resolve('write9.txt');
|
|
fs.open(filename, 'w', 0o644, common.mustSucceed((fd) => {
|
|
assert.throws(() => {
|
|
fs.write(fd,
|
|
buf,
|
|
0,
|
|
0x7FFFFFFF + 1,
|
|
0,
|
|
common.mustNotCall());
|
|
}, {
|
|
code: 'ERR_OUT_OF_RANGE',
|
|
name: 'RangeError',
|
|
message: 'The value of "length" is out of range. ' +
|
|
'It must be >= 0 && <= 2147483647. Received 2147483648'
|
|
});
|
|
|
|
fs.closeSync(fd);
|
|
}));
|