From f25f58438c7ba8e34bb4aeef7ef4ad6aa7fa7220 Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Thu, 6 Apr 2023 13:18:04 +0000 Subject: [PATCH] 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