mirror of
https://github.com/nodejs/node.git
synced 2025-05-20 19:03:09 +00:00

The `flag` and `mode` options were not being validated correctly. Signed-off-by: James M Snell <jasnell@gmail.com> Fixes: https://github.com/nodejs/node/issues/37430 PR-URL: https://github.com/nodejs/node/pull/37480 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
40 lines
856 B
JavaScript
40 lines
856 B
JavaScript
'use strict';
|
|
|
|
// Checks for crash regression: https://github.com/nodejs/node/issues/37430
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const {
|
|
open,
|
|
openSync,
|
|
promises: {
|
|
open: openPromise,
|
|
},
|
|
} = require('fs');
|
|
|
|
// These should throw, not crash.
|
|
|
|
assert.throws(() => open(__filename, 2176057344, common.mustNotCall()), {
|
|
code: 'ERR_OUT_OF_RANGE'
|
|
});
|
|
|
|
assert.throws(() => open(__filename, 0, 2176057344, common.mustNotCall()), {
|
|
code: 'ERR_OUT_OF_RANGE'
|
|
});
|
|
|
|
assert.throws(() => openSync(__filename, 2176057344), {
|
|
code: 'ERR_OUT_OF_RANGE'
|
|
});
|
|
|
|
assert.throws(() => openSync(__filename, 0, 2176057344), {
|
|
code: 'ERR_OUT_OF_RANGE'
|
|
});
|
|
|
|
assert.rejects(openPromise(__filename, 2176057344), {
|
|
code: 'ERR_OUT_OF_RANGE'
|
|
});
|
|
|
|
assert.rejects(openPromise(__filename, 0, 2176057344), {
|
|
code: 'ERR_OUT_OF_RANGE'
|
|
});
|