crypto: replace THROW with CHECK for scrypt keylen
The JS layer already uses validateInt32(keylen, 'keylen', 0) to ensure that the keylen argument fits into a signed 32-bit integer, thus, the THROW statement in C++ is unreachable (unless the binding is accessed directly, of course). PR-URL: https://github.com/nodejs/node/pull/47407 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
c311dc43cd
commit
1cda3f36d0
@ -109,10 +109,7 @@ Maybe<bool> ScryptTraits::AdditionalConfig(
|
||||
}
|
||||
|
||||
params->length = args[offset + 6].As<Int32>()->Value();
|
||||
if (params->length < 0) {
|
||||
THROW_ERR_OUT_OF_RANGE(env, "length must be <= %d", INT_MAX);
|
||||
return Nothing<bool>();
|
||||
}
|
||||
CHECK_GE(params->length, 0);
|
||||
|
||||
return Just(true);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user