Skip to content

Commit efd2b91

Browse files
committed
Address review comments
1 parent 2ca9712 commit efd2b91

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/internal/crypto/random.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ function randomFill(buf, offset, size, callback) {
124124
// e.g.: Buffer.from("ff".repeat(6), "hex").readUIntBE(0, 6);
125125
const RAND_MAX = 0xFFFF_FFFF_FFFF;
126126

127-
// Cache random data to use in randomInt.
128-
const randomCache = new FastBuffer(3072);
127+
// Cache random data to use in randomInt. The cache size must be evenly
128+
// divisible by 6 because each attempt to obtain a random int uses 6 bytes.
129+
const randomCache = new FastBuffer(6 * 1024);
129130
let randomCacheOffset = randomCache.length;
130131
let asyncCacheFillInProgress = false;
131132
const asyncCachePendingTasks = [];

0 commit comments

Comments
 (0)