test,doc: cover and document multi-byte offset/size in randomFill · nodejs/node@7fc8a3a · GitHub
Skip to content

Commit 7fc8a3a

Browse files
kyungrae2002aduh95
authored andcommitted
test,doc: cover and document multi-byte offset/size in randomFill
Signed-off-by: kyungrae <kyungrae2002@gmail.com> PR-URL: #64834 Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
1 parent 9633bb0 commit 7fc8a3a

3 files changed

Lines changed: 62 additions & 7 deletions

File tree

doc/api/crypto.md

Lines changed: 12 additions & 6 deletions

lib/internal/crypto/random.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ function randomFill(buf, offset, size, callback) {
168168
size = buf.length;
169169
} else if (typeof size === 'function') {
170170
callback = size;
171-
size = buf.length - offset;
171+
size = (buf.length ?? buf.byteLength) - offset;
172172
} else {
173173
validateFunction(callback, 'callback');
174174
}

test/parallel/test-crypto-random.js

Lines changed: 49 additions & 0 deletions

0 commit comments

Comments
 (0)