Tests api.c: rework for malloc failure testing

Modified number of tests to not crash on failure and cleanup allocations
on failure.
Added memory fail count option to set which memory allocation to start
failing on.
Fix issues found from testing.

bio.c:
BIO_new() move ref count up so that calls to wolfSSL_BIO_free()
work.
internal.c:
ImportCipherSpecState wasn't checking SetKeySide for failure. Crash
when pointer is NULL and accessed directly.
ocsp.c:
wolfSSL_OCSP_response_get1_basic() doesn't need to free vs->source
as it is freed in WOLFSSL_OCSP_RESPONSE_free().
ssl.c:
ProcessBuffer() Don't strip PKCS#8 header if failed to create DER.
Crasged as directly accessing 'der' which was NULL.
ssl_asn.c:
wolfssl_asn1_integer_require_len was checking wrong variable to see
if allocation failed.
x509,c:
wolfSSL_X509_ALGOR_set0 needs to set aobj only when no failure
possible.
wolfSSL_X509_chain_up_ref needs to call cleanup to ensure everything
is freed.
This commit is contained in:
Sean Parkinson
2023-05-26 15:49:14 +10:00
parent 37c03e3f11
commit 541ea51ad5
14 changed files with 3888 additions and 3252 deletions

View File

@@ -913,6 +913,7 @@ static int ImportCipherSpecState(WOLFSSL* ssl, const byte* exp, word32 len,
word32 tmp_seq_peer_hi;
word32 tmp_seq_lo;
word32 tmp_seq_hi;
int ret;
WOLFSSL_ENTER("ImportCipherSpecState");
@@ -951,7 +952,9 @@ static int ImportCipherSpecState(WOLFSSL* ssl, const byte* exp, word32 len,
tmp_seq_lo = ssl->keys.sequence_number_lo;
tmp_seq_hi = ssl->keys.sequence_number_hi;
SetKeysSide(ssl, ENCRYPT_AND_DECRYPT_SIDE);
if ((ret = SetKeysSide(ssl, ENCRYPT_AND_DECRYPT_SIDE)) < 0) {
return ret;
}
/* reset sequence numbers after setting keys */
ssl->keys.peer_sequence_number_lo = tmp_seq_peer_lo;