From 27b1a40bdd2ac826415d61323f6627c4504f6c8d Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Mon, 6 Jul 2026 22:48:11 +0200 Subject: [PATCH] tests: fix AUTHORITY_INFO_ACCESS leak under OPENSSL_EXTRA-only builds This branch widened test_wolfSSL_X509V3_EXT's guard from OPENSSL_ALL to (OPENSSL_EXTRA || OPENSSL_ALL). The Authority Info Access sub-test frees its aia stack with wolfSSL_sk_ACCESS_DESCRIPTION_pop_free(aia, NULL), relying on the stack's type-based element free - but wolfssl_sk_get_free_func() only wires up wolfSSL_ACCESS_DESCRIPTION_free for STACK_TYPE_ACCESS_DESCRIPTION under OPENSSL_ALL. In an OPENSSL_EXTRA-only build (now reachable) the NULL callback frees the stack nodes but leaks each ACCESS_DESCRIPTION (struct + method OBJ + location GENERAL_NAME + URI string): 370 bytes, caught by ASAN/valgrind. Pass wolfSSL_ACCESS_DESCRIPTION_free explicitly (available under OPENSSL_EXTRA); correct under OPENSSL_ALL too. Verified leak-free under ASAN with the failing config (--enable-opensslextra --enable-crl ... --disable-fastmath). --- tests/api/test_ossl_x509_ext.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/api/test_ossl_x509_ext.c b/tests/api/test_ossl_x509_ext.c index 06fdab92cd..cbceb8047d 100644 --- a/tests/api/test_ossl_x509_ext.c +++ b/tests/api/test_ossl_x509_ext.c @@ -1645,7 +1645,11 @@ int test_wolfSSL_X509V3_EXT(void) ExpectNull(wolfSSL_sk_ACCESS_DESCRIPTION_value(NULL, 0)); ExpectNull(wolfSSL_sk_ACCESS_DESCRIPTION_value(aia, 1)); ExpectNotNull(wolfSSL_sk_ACCESS_DESCRIPTION_value(aia, 0)); - wolfSSL_sk_ACCESS_DESCRIPTION_pop_free(aia, NULL); + /* Pass the element free explicitly: the stack's default (type-based) element + * free for ACCESS_DESCRIPTION is only wired up under OPENSSL_ALL, so with a + * NULL callback an OPENSSL_EXTRA-only build (this block now compiles there) + * frees the stack nodes but leaks each ACCESS_DESCRIPTION. */ + wolfSSL_sk_ACCESS_DESCRIPTION_pop_free(aia, wolfSSL_ACCESS_DESCRIPTION_free); aia = NULL; #ifndef NO_WOLFSSL_STUB