Skip to content

Commit c980286

Browse files
panvatargos
authored andcommitted
crypto: fix error when getRandomValues is called without arguments
PR-URL: #45854 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
1 parent 6e3d7f8 commit c980286

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
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)) {

test/wpt/status/WebCryptoAPI.json

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"fail": {
1010
"expected": [
1111
"Crypto interface: existence and properties of interface object",
12-
"Crypto interface: calling getRandomValues(ArrayBufferView) on crypto with too few arguments must throw TypeError",
1312
"CryptoKey interface: existence and properties of interface object",
1413
"CryptoKey interface: existence and properties of interface prototype object",
1514
"CryptoKey interface: attribute type",

0 commit comments

Comments
 (0)