GeezerVison is showing github.com — crypto: reduce range of size to int max · nodejs/node@723977f
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/crypto/random.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -31,8 +31,8 @@ const { |
31 | 31 | const { isArrayBufferView } = require('internal/util/types'); |
32 | 32 | const { FastBuffer } = require('internal/buffer'); |
33 | 33 |
|
34 | | -const kMaxUint32 = 2 ** 32 - 1; |
35 | | -const kMaxPossibleLength = MathMin(kMaxLength, kMaxUint32); |
| 34 | +const kMaxInt32 = 2 ** 31 - 1; |
| 35 | +const kMaxPossibleLength = MathMin(kMaxLength, kMaxInt32); |
36 | 36 |
|
37 | 37 | function assertOffset(offset, elementSize, length) { |
38 | 38 | validateNumber(offset, 'offset'); |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-crypto-random.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -31,8 +31,8 @@ const crypto = require('crypto'); |
31 | 31 | const { kMaxLength } = require('buffer'); |
32 | 32 | const { inspect } = require('util'); |
33 | 33 |
|
34 | | -const kMaxUint32 = Math.pow(2, 32) - 1; |
35 | | -const kMaxPossibleLength = Math.min(kMaxLength, kMaxUint32); |
| 34 | +const kMaxInt32 = 2 ** 31 - 1; |
| 35 | +const kMaxPossibleLength = Math.min(kMaxLength, kMaxInt32); |
36 | 36 |
|
37 | 37 | common.expectWarning('DeprecationWarning', |
38 | 38 | 'crypto.pseudoRandomBytes is deprecated.', 'DEP0115'); |
@@ -50,7 +50,7 @@ common.expectWarning('DeprecationWarning', |
50 | 50 | assert.throws(() => f(value, common.mustNotCall()), errObj); |
51 | 51 | }); |
52 | 52 |
|
53 | | - [-1, NaN, 2 ** 32].forEach((value) => { |
| 53 | + [-1, NaN, 2 ** 32, 2 ** 31].forEach((value) => { |
54 | 54 | const errObj = { |
55 | 55 | code: 'ERR_OUT_OF_RANGE', |
56 | 56 | name: 'RangeError', |
|