From f25f58438c7ba8e34bb4aeef7ef4ad6aa7fa7220 Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Thu, 6 Apr 2023 13:18:04 +0000 Subject: [PATCH 1/2] unit tests: include an OpenSSL header before including cmocka.h OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a redefined malloc in cmocka.h. As a workaround, include an OpenSSL header file before including cmocka.h in the unit tests where OpenSSL is used. (cherry picked from commit 87db9ea84cb72ef9be3779e94407ccee7f8f2a4a) --- tests/dns/dh_test.c | 7 +++++++ tests/dns/dst_test.c | 7 +++++++ tests/dns/rsa_test.c | 7 +++++++ tests/isc/doh_test.c | 7 +++++++ tests/isc/hmac_test.c | 7 +++++++ tests/isc/netmgr_test.c | 7 +++++++ 6 files changed, 42 insertions(+) diff --git a/tests/dns/dh_test.c b/tests/dns/dh_test.c index 246de2197a..9358a8f61f 100644 --- a/tests/dns/dh_test.c +++ b/tests/dns/dh_test.c @@ -19,6 +19,13 @@ #include #include +/* + * As a workaround, include an OpenSSL header file before including cmocka.h, + * because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a + * redefined malloc in cmocka.h. + */ +#include + #define UNIT_TESTING #include diff --git a/tests/dns/dst_test.c b/tests/dns/dst_test.c index f18bd2f359..0fecb908ea 100644 --- a/tests/dns/dst_test.c +++ b/tests/dns/dst_test.c @@ -19,6 +19,13 @@ #include #include +/* + * As a workaround, include an OpenSSL header file before including cmocka.h, + * because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a + * redefined malloc in cmocka.h. + */ +#include + #define UNIT_TESTING #include diff --git a/tests/dns/rsa_test.c b/tests/dns/rsa_test.c index 40652541f5..c814ab68d9 100644 --- a/tests/dns/rsa_test.c +++ b/tests/dns/rsa_test.c @@ -20,6 +20,13 @@ #include #include +/* + * As a workaround, include an OpenSSL header file before including cmocka.h, + * because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a + * redefined malloc in cmocka.h. + */ +#include + #define UNIT_TESTING #include diff --git a/tests/isc/doh_test.c b/tests/isc/doh_test.c index ab74813cff..090fb8f318 100644 --- a/tests/isc/doh_test.c +++ b/tests/isc/doh_test.c @@ -22,6 +22,13 @@ #include #include +/* + * As a workaround, include an OpenSSL header file before including cmocka.h, + * because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a + * redefined malloc in cmocka.h. + */ +#include + #define UNIT_TESTING #include diff --git a/tests/isc/hmac_test.c b/tests/isc/hmac_test.c index ac567d6884..3d459d0a18 100644 --- a/tests/isc/hmac_test.c +++ b/tests/isc/hmac_test.c @@ -20,6 +20,13 @@ #include #include +/* + * As a workaround, include an OpenSSL header file before including cmocka.h, + * because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a + * redefined malloc in cmocka.h. + */ +#include + #define UNIT_TESTING #include diff --git a/tests/isc/netmgr_test.c b/tests/isc/netmgr_test.c index 1527c68112..b2745521f7 100644 --- a/tests/isc/netmgr_test.c +++ b/tests/isc/netmgr_test.c @@ -19,6 +19,13 @@ #include #include +/* + * As a workaround, include an OpenSSL header file before including cmocka.h, + * because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a + * redefined malloc in cmocka.h. + */ +#include + #define UNIT_TESTING #include From 2b85e3603ea11fbfda08d4a7e61b5595b981933d Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Thu, 6 Apr 2023 13:22:46 +0000 Subject: [PATCH 2/2] Add a CHANGES note for [GL #4000] (cherry picked from commit 786b0689c616e7d43e01ab19eb95bc913f20359a) --- CHANGES | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES b/CHANGES index cc153cb29d..9c3e14cdd4 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +6149. [test] As a workaround, include an OpenSSL header file before + including cmocka.h in the unit tests, because OpenSSL + 3.1.0 uses __attribute__(malloc), conflicting with a + redefined malloc in cmocka.h. [GL #4000] + 6145. [bug] Fix a possible use-after-free bug in the dns__catz_done_cb() function. [GL #3997]