diff --git a/src/crypto/crypto_scrypt.cc b/src/crypto/crypto_scrypt.cc index 88d355446c0984..4dae07f13604d4 100644 --- a/src/crypto/crypto_scrypt.cc +++ b/src/crypto/crypto_scrypt.cc @@ -109,10 +109,7 @@ Maybe ScryptTraits::AdditionalConfig( } params->length = args[offset + 6].As()->Value(); - if (params->length < 0) { - THROW_ERR_OUT_OF_RANGE(env, "length must be <= %d", INT_MAX); - return Nothing(); - } + CHECK_GE(params->length, 0); return Just(true); } diff --git a/test/parallel/test-crypto-scrypt.js b/test/parallel/test-crypto-scrypt.js index 63656e056f195a..73bf0217b1fb67 100644 --- a/test/parallel/test-crypto-scrypt.js +++ b/test/parallel/test-crypto-scrypt.js @@ -143,10 +143,18 @@ const badargs = [ args: ['', '', -42], expected: { code: 'ERR_OUT_OF_RANGE', message: /"keylen"/ }, }, + { + args: ['', '', 2 ** 31], + expected: { code: 'ERR_OUT_OF_RANGE', message: /"keylen"/ }, + }, { args: ['', '', 2147485780], expected: { code: 'ERR_OUT_OF_RANGE', message: /"keylen"/ }, }, + { + args: ['', '', 2 ** 32], + expected: { code: 'ERR_OUT_OF_RANGE', message: /"keylen"/ }, + }, ]; for (const options of good) {