Skip to content

Commit 4add368

Browse files
tniessendanielleadams
authored andcommitted
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: #47168 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent dd42214 commit 4add368

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/crypto/crypto_dsa.cc

+1-5
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,12 @@ Maybe<bool> DsaKeyGenTraits::AdditionalConfig(
8383
const FunctionCallbackInfo<Value>& args,
8484
unsigned int* offset,
8585
DsaKeyPairGenConfig* params) {
86-
Environment* env = Environment::GetCurrent(args);
8786
CHECK(args[*offset]->IsUint32()); // modulus bits
8887
CHECK(args[*offset + 1]->IsInt32()); // divisor bits
8988

9089
params->params.modulus_bits = args[*offset].As<Uint32>()->Value();
9190
params->params.divisor_bits = args[*offset + 1].As<Int32>()->Value();
92-
if (params->params.divisor_bits < -1) {
93-
THROW_ERR_OUT_OF_RANGE(env, "invalid value for divisor_bits");
94-
return Nothing<bool>();
95-
}
91+
CHECK_GE(params->params.divisor_bits, -1);
9692

9793
*offset += 2;
9894

test/parallel/test-crypto-keygen.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
12781278
}
12791279

12801280
// Test invalid divisor lengths. (out of range)
1281-
for (const divisorLength of [-6, -9, 2147483648]) {
1281+
for (const divisorLength of [-1, -6, -9, 2147483648]) {
12821282
assert.throws(() => generateKeyPair('dsa', {
12831283
modulusLength: 2048,
12841284
divisorLength

0 commit comments

Comments
 (0)