]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Disable OpenSSL memory contexts for OpenSSL < 3.0.0
authorOndřej Surý <ondrej@isc.org>
Thu, 19 Oct 2023 09:39:53 +0000 (11:39 +0200)
committerOndřej Surý <ondrej@isc.org>
Thu, 19 Oct 2023 10:54:40 +0000 (12:54 +0200)
OpenSSL 1.1 has already reached end-of-life and since we are
experiencing a weird memory leak in the mirror system test on just
Ubuntu 20.04 (Focal) with OpenSSL 1.1, we disable the legacy code for
enabling memory contexts for OpenSSL < 3.0.0 in this commit.

lib/isc/tls.c

index e6996f43a621f5be5c4bc0827b4aa5da552661e9..e92f5af91ad9c490688a9444755e20f828239acf 100644 (file)
@@ -83,7 +83,7 @@ static atomic_bool handle_fatal = false;
 static atomic_bool handle_fatal = true;
 #endif
 
-#if !defined(LIBRESSL_VERSION_NUMBER)
+#if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x30000000L
 /*
  * This was crippled with LibreSSL, so just skip it:
  * https://cvsweb.openbsd.org/src/lib/libcrypto/Attic/mem.c
@@ -150,14 +150,6 @@ isc__tls_free_ex(void *ptr, const char *file, int line) {
 
 #endif /* ISC_MEM_TRACKLINES */
 
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
-static void
-isc__tls_free(void *ptr) {
-       isc__tls_free_ex(ptr, __FILE__, __LINE__);
-}
-
-#endif
-
 #endif /* !defined(LIBRESSL_VERSION_NUMBER) */
 
 void
@@ -166,20 +158,16 @@ isc__tls_initialize(void) {
        isc_mem_setname(isc__tls_mctx, "OpenSSL");
        isc_mem_setdestroycheck(isc__tls_mctx, false);
 
-#if !defined(LIBRESSL_VERSION_NUMBER)
+#if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x30000000L
        /*
         * CRYPTO_set_mem_(_ex)_functions() returns 1 on success or 0 on
         * failure, which means OpenSSL already allocated some memory.  There's
         * nothing we can do about it.
         */
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
        (void)CRYPTO_set_mem_functions(isc__tls_malloc_ex, isc__tls_realloc_ex,
                                       isc__tls_free_ex);
-#else
-       (void)CRYPTO_set_mem_ex_functions(isc__tls_malloc_ex,
-                                         isc__tls_realloc_ex, isc__tls_free);
-#endif
-#endif /* !defined(LIBRESSL_VERSION_NUMBER) */
+#endif /* !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= \
+         0x30000000L  */
 
 #if OPENSSL_VERSION_NUMBER >= 0x10100000L
        uint64_t opts = OPENSSL_INIT_ENGINE_ALL_BUILTIN |