GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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
Filter options
  • lib/internal/crypto
    • random.js
  • test/parallel
    • test-crypto-random.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/crypto/random.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/random.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ const {
3131
const { isArrayBufferView } = require('internal/util/types');
3232
const { FastBuffer } = require('internal/buffer');
3333

34-
const kMaxUint32 = 2 ** 32 - 1;
35-
const kMaxPossibleLength = MathMin(kMaxLength, kMaxUint32);
34+
const kMaxInt32 = 2 ** 31 - 1;
35+
const kMaxPossibleLength = MathMin(kMaxLength, kMaxInt32);
3636

3737
function assertOffset(offset, elementSize, length) {
3838
validateNumber(offset, 'offset');
Collapse file

‎test/parallel/test-crypto-random.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-crypto-random.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ const crypto = require('crypto');
3131
const { kMaxLength } = require('buffer');
3232
const { inspect } = require('util');
3333

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);
3636

3737
common.expectWarning('DeprecationWarning',
3838
'crypto.pseudoRandomBytes is deprecated.', 'DEP0115');
@@ -50,7 +50,7 @@ common.expectWarning('DeprecationWarning',
5050
assert.throws(() => f(value, common.mustNotCall()), errObj);
5151
});
5252

53-
[-1, NaN, 2 ** 32].forEach((value) => {
53+
[-1, NaN, 2 ** 32, 2 ** 31].forEach((value) => {
5454
const errObj = {
5555
code: 'ERR_OUT_OF_RANGE',
5656
name: 'RangeError',

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.