lib/hcrypto: RSA_check_key if rsa->n is NULL cannot call RSA_size

Avoid a theoretical NULL pointer dereference.

Change-Id: Ia7b8671152b5444fd5cfdb3e37fd62e4db68c9c5
This commit is contained in:
Jeffrey Altman
2022-01-17 21:36:49 -05:00
parent ee3cd2e4a9
commit 1ebebe1d2f

View File

@@ -272,7 +272,10 @@ RSA_check_key(const RSA *key)
* and then decrypt/verify.
*/
if ((rsa->d == NULL || rsa->n == NULL) &&
if (rsa->n == NULL)
return 0;
if (rsa->d == NULL &&
(rsa->p == NULL || rsa->q || rsa->dmp1 == NULL || rsa->dmq1 == NULL || rsa->iqmp == NULL))
return 0;