unmask malloc returning NULL

This commit is contained in:
Tesfa Mael
2022-11-15 11:26:29 -08:00
parent 9036c098b0
commit 647ce794dd
4 changed files with 27 additions and 4 deletions

View File

@ -75,6 +75,9 @@ int InitCRL(WOLFSSL_CRL* crl, WOLFSSL_CERT_MANAGER* cm)
WOLFSSL_MSG("Pthread condition init failed"); WOLFSSL_MSG("Pthread condition init failed");
return BAD_COND_E; return BAD_COND_E;
} }
#endif
#ifdef HAVE_CRL_IO
crl->crlIOCb = NULL;
#endif #endif
if (wc_InitMutex(&crl->crlLock) != 0) { if (wc_InitMutex(&crl->crlLock) != 0) {
WOLFSSL_MSG("Init Mutex failed"); WOLFSSL_MSG("Init Mutex failed");

View File

@ -32339,6 +32339,10 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
int doHelloRetry = 0; int doHelloRetry = 0;
/* Try to establish a key share. */ /* Try to establish a key share. */
int ret = TLSX_KeyShare_Establish(ssl, &doHelloRetry); int ret = TLSX_KeyShare_Establish(ssl, &doHelloRetry);
if (ret != 0) {
return ret;
}
if (doHelloRetry) { if (doHelloRetry) {
ssl->options.serverState = SERVER_HELLO_RETRY_REQUEST_COMPLETE; ssl->options.serverState = SERVER_HELLO_RETRY_REQUEST_COMPLETE;
} }
@ -32386,6 +32390,10 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
} }
else { else {
WOLFSSL_MSG("Could not verify suite validity, continue"); WOLFSSL_MSG("Could not verify suite validity, continue");
if (ret == MEMORY_E) {
WOLFSSL_MSG("Out of memory error");
return ret;
}
} }
} }

View File

@ -35538,6 +35538,7 @@ static int GetRevoked(RevokedCert* rcert, const byte* buff, word32* idx,
ret = wc_GetSerialNumber(buff, idx, rc->serialNumber, &rc->serialSz,maxIdx); ret = wc_GetSerialNumber(buff, idx, rc->serialNumber, &rc->serialSz,maxIdx);
if (ret < 0) { if (ret < 0) {
WOLFSSL_MSG("wc_GetSerialNumber error"); WOLFSSL_MSG("wc_GetSerialNumber error");
XFREE(rc, dcrl->heap, DYNAMIC_TYPE_REVOKED);
return ret; return ret;
} }
/* add to list */ /* add to list */

View File

@ -7847,6 +7847,8 @@ int ecc_mul2add(ecc_point* A, mp_int* kA,
res Result of signature, 1==valid, 0==invalid res Result of signature, 1==valid, 0==invalid
key The corresponding public ECC key key The corresponding public ECC key
return MP_OKAY if successful (even if the signature is not valid) return MP_OKAY if successful (even if the signature is not valid)
Caller should check the *res value to determine if the signature
is valid or invalid. Other negative values are returned on error.
*/ */
WOLFSSL_ABI WOLFSSL_ABI
int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash, int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
@ -8032,7 +8034,6 @@ static int wc_ecc_check_r_s_range(ecc_key* key, mp_int* r, mp_int* s)
} }
#endif /* !WOLFSSL_STM32_PKA && !WOLFSSL_PSOC6_CRYPTO */ #endif /* !WOLFSSL_STM32_PKA && !WOLFSSL_PSOC6_CRYPTO */
/** /**
Verify an ECC signature Verify an ECC signature
r The signature R component to verify r The signature R component to verify
@ -8042,6 +8043,8 @@ static int wc_ecc_check_r_s_range(ecc_key* key, mp_int* r, mp_int* s)
res Result of signature, 1==valid, 0==invalid res Result of signature, 1==valid, 0==invalid
key The corresponding public ECC key key The corresponding public ECC key
return MP_OKAY if successful (even if the signature is not valid) return MP_OKAY if successful (even if the signature is not valid)
Caller should check the *res value to determine if the signature
is valid or invalid. Other negative values are returned on error.
*/ */
#ifndef WOLF_CRYPTO_CB_ONLY_ECC #ifndef WOLF_CRYPTO_CB_ONLY_ECC
int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash, int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
@ -8182,12 +8185,20 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
(byte*)hash, (byte*)hash,
msgLenInBytes); msgLenInBytes);
if (err != SA_SILIB_RET_OK) { if (err == CRYS_ECDSA_VERIFY_INCONSISTENT_VERIFY_ERROR) {
/* signature verification reported invalid signature. */
*res = 0; /* Redundant, added for code clarity */
err = MP_OKAY;
}
else if (err != SA_SILIB_RET_OK) {
WOLFSSL_MSG("CRYS_ECDSA_Verify failed"); WOLFSSL_MSG("CRYS_ECDSA_Verify failed");
return err; return err;
} }
/* valid signature if we get to this point */ else {
*res = 1; /* valid signature. */
*res = 1;
err = MP_OKAY;
}
#elif defined(WOLFSSL_SILABS_SE_ACCEL) #elif defined(WOLFSSL_SILABS_SE_ACCEL)
err = silabs_ecc_verify_hash(&sigRS[0], keySz * 2, err = silabs_ecc_verify_hash(&sigRS[0], keySz * 2,
hash, hashlen, hash, hashlen,