mirror of https://github.com/nodejs/node.git
crypto: reduce range of size to int max
Refs: https://github.com/nodejs/node/issues/38090 PR-URL: https://github.com/nodejs/node/pull/38096 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This commit is contained in:
parent
8dd06850ae
commit
993ed19f9c
|
@ -57,8 +57,8 @@ const {
|
|||
|
||||
const { FastBuffer } = require('internal/buffer');
|
||||
|
||||
const kMaxUint32 = 2 ** 32 - 1;
|
||||
const kMaxPossibleLength = MathMin(kMaxLength, kMaxUint32);
|
||||
const kMaxInt32 = 2 ** 31 - 1;
|
||||
const kMaxPossibleLength = MathMin(kMaxLength, kMaxInt32);
|
||||
|
||||
function assertOffset(offset, elementSize, length) {
|
||||
validateNumber(offset, 'offset');
|
||||
|
|
|
@ -32,8 +32,8 @@ const cryptop = require('crypto').webcrypto;
|
|||
const { kMaxLength } = require('buffer');
|
||||
const { inspect } = require('util');
|
||||
|
||||
const kMaxUint32 = Math.pow(2, 32) - 1;
|
||||
const kMaxPossibleLength = Math.min(kMaxLength, kMaxUint32);
|
||||
const kMaxInt32 = 2 ** 31 - 1;
|
||||
const kMaxPossibleLength = Math.min(kMaxLength, kMaxInt32);
|
||||
|
||||
common.expectWarning('DeprecationWarning',
|
||||
'crypto.pseudoRandomBytes is deprecated.', 'DEP0115');
|
||||
|
@ -51,7 +51,7 @@ common.expectWarning('DeprecationWarning',
|
|||
assert.throws(() => f(value, common.mustNotCall()), errObj);
|
||||
});
|
||||
|
||||
[-1, NaN, 2 ** 32].forEach((value) => {
|
||||
[-1, NaN, 2 ** 32, 2 ** 31].forEach((value) => {
|
||||
const errObj = {
|
||||
code: 'ERR_OUT_OF_RANGE',
|
||||
name: 'RangeError',
|
||||
|
|
Loading…
Reference in New Issue