From 228544c31ee2cf20d96caa86d7b34ce1a69588ae Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Tue, 19 Mar 2024 02:44:45 +0700 Subject: [PATCH 1/2] CID 327280 use after free in test case --- tests/api.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/api.c b/tests/api.c index c6bd6ef5e..a37b880fd 100644 --- a/tests/api.c +++ b/tests/api.c @@ -2304,7 +2304,9 @@ static int test_wolfSSL_CertManagerAPI(void) #endif ExpectIntEQ(wolfSSL_CertManager_up_ref(cm), 1); - wolfSSL_CertManagerFree(cm); + if (EXPECT_SUCCESS()) { + wolfSSL_CertManagerFree(cm); + } wolfSSL_CertManagerFree(cm); cm = NULL; From 489a79ad8ba8525529b990c0170bbfd0a3c94998 Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Tue, 19 Mar 2024 02:59:06 +0700 Subject: [PATCH 2/2] CID 347893 set test cert manager to null after free --- tests/api.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/api.c b/tests/api.c index a37b880fd..71a2b0ee7 100644 --- a/tests/api.c +++ b/tests/api.c @@ -63332,10 +63332,12 @@ static int test_various_pathlen_chains(void) #endif /* NO_WOLFSSL_CLIENT && NO_WOLFSSL_SERVER */ ExpectIntEQ(wolfSSL_CertManagerUnloadCAs(cm), WOLFSSL_SUCCESS); wolfSSL_CertManagerFree(cm); + cm = NULL; ExpectNotNull(cm = wolfSSL_CertManagerNew()); ExpectIntEQ(wolfSSL_CertManagerUnloadCAs(cm), WOLFSSL_SUCCESS); wolfSSL_CertManagerFree(cm); + cm = NULL; /* Test chain J (Again only first ICA has pathLen set and it's set to 2, * this time followed by 3 ICA's, should fail */ @@ -63343,6 +63345,7 @@ static int test_various_pathlen_chains(void) ExpectIntLT(test_chainJ(cm), 0); ExpectIntEQ(wolfSSL_CertManagerUnloadCAs(cm), WOLFSSL_SUCCESS); wolfSSL_CertManagerFree(cm); + cm = NULL; ExpectNotNull(cm = wolfSSL_CertManagerNew()); ExpectIntEQ(wolfSSL_CertManagerUnloadCAs(cm), WOLFSSL_SUCCESS);