forked from wolfSSL/wolfssl
coverity issue 394701 possible derefernce before null check
This commit is contained in:
@ -673,13 +673,17 @@ static int _ifc_pairwise_consistency_test(RsaKey* key, WC_RNG* rng)
|
|||||||
|
|
||||||
int wc_CheckRsaKey(RsaKey* key)
|
int wc_CheckRsaKey(RsaKey* key)
|
||||||
{
|
{
|
||||||
DECL_MP_INT_SIZE_DYN(tmp, mp_bitsused(&key->n), RSA_MAX_SIZE);
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
WC_RNG *rng = NULL;
|
WC_RNG *rng = NULL;
|
||||||
#else
|
#else
|
||||||
WC_RNG rng[1];
|
WC_RNG rng[1];
|
||||||
#endif
|
#endif
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
DECL_MP_INT_SIZE_DYN(tmp, (key)? mp_bitsused(&key->n) : 0, RSA_MAX_SIZE);
|
||||||
|
|
||||||
|
if (key == NULL) {
|
||||||
|
return BAD_FUNC_ARG;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WOLFSSL_CAAM
|
#ifdef WOLFSSL_CAAM
|
||||||
/* can not perform these checks on an encrypted key */
|
/* can not perform these checks on an encrypted key */
|
||||||
@ -711,11 +715,6 @@ int wc_CheckRsaKey(RsaKey* key)
|
|||||||
ret = MP_INIT_E;
|
ret = MP_INIT_E;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == 0) {
|
|
||||||
if (key == NULL)
|
|
||||||
ret = BAD_FUNC_ARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
ret = _ifc_pairwise_consistency_test(key, rng);
|
ret = _ifc_pairwise_consistency_test(key, rng);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user