Skip to content

Commit c643645

Browse files
panvajuanarbol
authored andcommittedJan 24, 2023
crypto: fix error when getRandomValues is called without arguments
PR-URL: #45854 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent 5eb93f1 commit c643645

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed
 

‎lib/internal/crypto/random.js

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const { Buffer, kMaxLength } = require('buffer');
4040
const {
4141
codes: {
4242
ERR_INVALID_ARG_TYPE,
43+
ERR_MISSING_ARGS,
4344
ERR_OUT_OF_RANGE,
4445
ERR_OPERATION_FAILED,
4546
}
@@ -315,6 +316,8 @@ function onJobDone(buf, callback, error) {
315316
// not allowed to exceed 65536 bytes, and can only
316317
// be an integer-type TypedArray.
317318
function getRandomValues(data) {
319+
if (arguments.length < 1)
320+
throw new ERR_MISSING_ARGS('typedArray');
318321
if (!isTypedArray(data) ||
319322
isFloat32Array(data) ||
320323
isFloat64Array(data)) {

0 commit comments

Comments
 (0)
Please sign in to comment.