summaryrefslogtreecommitdiffstats
path: root/test/endecode_test.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2021-12-23 13:59:12 +0000
committerTomas Mraz <tomas@openssl.org>2022-11-09 15:30:43 +0100
commitec8ee00100faeddf149e70e1f0964f3a41b51545 (patch)
treec5fbacbb6587421a65451108212bd142ada2f6bb /test/endecode_test.c
parent0029f786658229b15f98741a336e8091305cbf15 (diff)
Statically link the legacy provider to endecode_test
We already statically link libcrypto to endecode_test even in a "shared" build. This can cause problems on some platforms with tests that load the legacy provider which is dynamically linked to libcrypto. Two versions of libcrypto are then linked to the same executable which can lead to crashes. Fixes #17059 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17345) (cherry picked from commit 7ee992a5d931ab5ad9df00d2d8e47e1b7a72d7ac) Reviewed-by: Hugo Landau <hlandau@openssl.org>
Diffstat (limited to 'test/endecode_test.c')
-rw-r--r--test/endecode_test.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/endecode_test.c b/test/endecode_test.c
index e3f7b81f69..14648287eb 100644
--- a/test/endecode_test.c
+++ b/test/endecode_test.c
@@ -26,6 +26,10 @@
#include "helpers/predefined_dhparams.h"
#include "testutil.h"
+#ifdef STATIC_LEGACY
+OSSL_provider_init_fn ossl_legacy_provider_init;
+#endif
+
/* Extended test macros to allow passing file & line number */
#define TEST_FL_ptr(a) test_ptr(file, line, #a, a)
#define TEST_FL_mem_eq(a, m, b, n) test_mem_eq(file, line, #a, #b, a, m, b, n)
@@ -1325,6 +1329,16 @@ int setup_tests(void)
if (is_fips_3_0_0 < 0)
return 0;
+#ifdef STATIC_LEGACY
+ /*
+ * This test is always statically linked against libcrypto. We must not
+ * attempt to load legacy.so that might be dynamically linked against
+ * libcrypto. Instead we use a built-in version of the legacy provider.
+ */
+ if (!OSSL_PROVIDER_add_builtin(testctx, "legacy", ossl_legacy_provider_init))
+ return 0;
+#endif
+
/* Separate provider/ctx for generating the test data */
if (!TEST_ptr(keyctx = OSSL_LIB_CTX_new()))
return 0;