mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
crypto: fix missing nullptr check on RSA_new()
Not checking this can cause a null deref. Since there is already a null check at the bottom of the function with `NewRSA()`. PR-URL: https://github.com/nodejs/node/pull/61888 Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
1 parent
fce2930110
commit
a32a598748
1 file changed
+9
-1
@@ -385,6 +385,11 @@ KeyObjectData ImportJWKRsaKey(Environment* env,
|
||||
KeyType type = d_value->IsString() ? kKeyTypePrivate : kKeyTypePublic;
|
||||
|
||||
RSAPointer rsa(RSA_new());
|
||||
if (!rsa) {
|
||||
THROW_ERR_CRYPTO_OPERATION_FAILED(env, "Unable to create RSA pointer");
|
||||
return {};
|
||||
}
|
||||
|
||||
ncrypto::Rsa rsa_view(rsa.get());
|
||||
|
||||
ByteSource n = ByteSource::FromEncodedString(env, n_value.As<String>());
|
||||
@@ -435,7 +440,10 @@ KeyObjectData ImportJWKRsaKey(Environment* env,
|
||||
}
|
||||
|
||||
auto pkey = EVPKeyPointer::NewRSA(std::move(rsa));
|
||||
if (!pkey) return {};
|
||||
if (!pkey) {
|
||||
THROW_ERR_CRYPTO_OPERATION_FAILED(env, "Unable to create key pointer");
|
||||
return {};
|
||||
}
|
||||
|
||||
return KeyObjectData::CreateAsymmetric(type, std::move(pkey));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user