src: replace impossible THROW with CHECK

The JS layer already verifies that divisor_bits is either a non-negative
32-bit signed integer or null/undefined, in which case it passes -1 to
the C++ layer. In either case, the C++ layer receives a 32-bit signed
integer greater than or equal to -1.

PR-URL: https://github.com/nodejs/node/pull/47168
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Tobias Nießen authored and RafaelGSS committed 2023-04-07 08:40:35 -03:00
1 parent 254a03b2eb
commit 0a4ff2f9a0
2 files changed
+2 -6

No files matched your search

+1 -5
View File
@@ -83,16 +83,12 @@ Maybe<bool> DsaKeyGenTraits::AdditionalConfig(
const FunctionCallbackInfo<Value>& args,
unsigned int* offset,
DsaKeyPairGenConfig* params) {
Environment* env = Environment::GetCurrent(args);
CHECK(args[*offset]->IsUint32()); // modulus bits
CHECK(args[*offset + 1]->IsInt32()); // divisor bits
params->params.modulus_bits = args[*offset].As<Uint32>()->Value();
params->params.divisor_bits = args[*offset + 1].As<Int32>()->Value();
if (params->params.divisor_bits < -1) {
THROW_ERR_OUT_OF_RANGE(env, "invalid value for divisor_bits");
return Nothing<bool>();
}
CHECK_GE(params->params.divisor_bits, -1);
*offset += 2;
+1 -1
View File
@@ -1278,7 +1278,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}
// Test invalid divisor lengths. (out of range)
for (const divisorLength of [-6, -9, 2147483648]) {
for (const divisorLength of [-1, -6, -9, 2147483648]) {
assert.throws(() => generateKeyPair('dsa', {
modulusLength: 2048,
divisorLength