Test api.c: change more tests to use Expect instead of Assert

bio.c:
  wolfSSL_BIO_flush(): check allocation to bio->ip succeeded.

internal.c:
  InitSSL_Ctx(): set ctx->heap to heap if value passed in
ProcessPeerCerts(): check for error MEMORY_E too as a fatal parsing
error

ssl.c:
wolfSSL_shutdown(): SOCKET_ERROR_E is also an indication that the
socket is done, MEMORY_E is a fatal error
  wolfSSL_Cleanup(): move free of memory fail couting to wolfSSL API
  SessionTicketNoncePrealloc(): eror return must be non-zero
AddSessionToCache(): XFREE checks for NULL no need to do it before
call
wolfSSL_set_psk_use_session_callback(): ensure ssl is not NULL before
dereferencing
wolfSSL_SMIME_read_PKCS7(): check for error return from
wolfSSL_BIO_gets()

asn.c:
  wc_MIME_parse_headers(): check allocation succeeded into nextHdr

compress.c:
  wc_DeCompressDynamic(): free tmp on inflateInit2 failure

memory.c: rework where memory allocation failure counting code for when
WOFLSSL_STATIC_MEMORY is defined

wc_port.c:
wolfCrypt_Cleanup(): only call wc_MemFailCount_Free() when no
wolfSSL_Cleanup()
This commit is contained in:
Sean Parkinson
2023-06-22 08:11:50 +10:00
parent 6697181081
commit 578f56e60c
9 changed files with 10676 additions and 16925 deletions

View File

@@ -2154,7 +2154,12 @@ int InitSSL_Ctx(WOLFSSL_CTX* ctx, WOLFSSL_METHOD* method, void* heap)
XMEMSET(ctx, 0, sizeof(WOLFSSL_CTX));
ctx->method = method;
ctx->heap = ctx; /* defaults to self */
if (heap == NULL) {
ctx->heap = ctx; /* defaults to self */
}
else {
ctx->heap = heap; /* wolfSSL_CTX_load_static_memory sets */
}
ctx->timeout = WOLFSSL_SESSION_TIMEOUT;
#ifdef WOLFSSL_DTLS
@@ -13591,6 +13596,12 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
if (ret == 0) {
ret = ProcessPeerCertCheckKey(ssl, args);
}
else if (ret == ASN_PARSE_E || ret == BUFFER_E ||
ret == MEMORY_E) {
WOLFSSL_MSG(
"Got Peer cert ASN PARSE_E, BUFFER E, MEMORY_E");
ERROR_OUT(ret, exit_ppc);
}
if (ret == 0 && args->dCert->isCA == 0) {
WOLFSSL_MSG("Chain cert is not a CA, not adding as one");
@@ -13875,8 +13886,9 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
args->fatal = 0;
}
}
else if (ret == ASN_PARSE_E || ret == BUFFER_E) {
WOLFSSL_MSG("Got Peer cert ASN PARSE or BUFFER ERROR");
else if (ret == ASN_PARSE_E || ret == BUFFER_E ||
ret == MEMORY_E) {
WOLFSSL_MSG("Got Peer cert ASN PARSE_E, BUFFER E, MEMORY_E");
#if defined(WOLFSSL_EXTRA_ALERTS) || defined(OPENSSL_EXTRA) || \
defined(OPENSSL_EXTRA_X509_SMALL)
DoCertFatalAlert(ssl, ret);