Add OPENSSL_cleanup to tls_shutdown function
This prevents a direct leak in OPENSSL_init_crypto (called from
OPENSSL_init_ssl).
Add shim version of OPENSSL_cleanup because it is missing in LibreSSL on
OpenBSD.
(cherry picked from commit 89f4f8f0c8)
This commit is contained in:
@@ -288,6 +288,9 @@
|
|||||||
/* Define to 1 if you have the <net/route.h> header file. */
|
/* Define to 1 if you have the <net/route.h> header file. */
|
||||||
#undef HAVE_NET_ROUTE_H
|
#undef HAVE_NET_ROUTE_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `OPENSSL_cleanup' function. */
|
||||||
|
#undef HAVE_OPENSSL_CLEANUP
|
||||||
|
|
||||||
/* define if OpenSSL supports Ed25519 */
|
/* define if OpenSSL supports Ed25519 */
|
||||||
#undef HAVE_OPENSSL_ED25519
|
#undef HAVE_OPENSSL_ED25519
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -832,7 +832,7 @@ AC_COMPILE_IFELSE(
|
|||||||
# Check for functions added in OpenSSL or LibreSSL
|
# Check for functions added in OpenSSL or LibreSSL
|
||||||
#
|
#
|
||||||
|
|
||||||
AC_CHECK_FUNCS([OPENSSL_init_ssl OPENSSL_init_crypto])
|
AC_CHECK_FUNCS([OPENSSL_init_ssl OPENSSL_init_crypto OPENSSL_cleanup])
|
||||||
AC_CHECK_FUNCS([CRYPTO_zalloc])
|
AC_CHECK_FUNCS([CRYPTO_zalloc])
|
||||||
AC_CHECK_FUNCS([EVP_CIPHER_CTX_new EVP_CIPHER_CTX_free])
|
AC_CHECK_FUNCS([EVP_CIPHER_CTX_new EVP_CIPHER_CTX_free])
|
||||||
AC_CHECK_FUNCS([EVP_MD_CTX_new EVP_MD_CTX_free EVP_MD_CTX_reset])
|
AC_CHECK_FUNCS([EVP_MD_CTX_new EVP_MD_CTX_free EVP_MD_CTX_reset])
|
||||||
|
|||||||
@@ -220,3 +220,10 @@ OPENSSL_init_ssl(uint64_t opts, const void *settings) {
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !HAVE_OPENSSL_CLEANUP
|
||||||
|
void
|
||||||
|
OPENSSL_cleanup(void) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -119,6 +119,11 @@ OPENSSL_init_ssl(uint64_t opts, const void *settings);
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !HAVE_OPENSSL_CLEANUP
|
||||||
|
void
|
||||||
|
OPENSSL_cleanup(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !HAVE_TLS_SERVER_METHOD
|
#if !HAVE_TLS_SERVER_METHOD
|
||||||
#define TLS_server_method SSLv23_server_method
|
#define TLS_server_method SSLv23_server_method
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+4
-2
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include <openssl/bn.h>
|
#include <openssl/bn.h>
|
||||||
#include <openssl/conf.h>
|
#include <openssl/conf.h>
|
||||||
|
#include <openssl/crypto.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
#include <openssl/opensslv.h>
|
#include <openssl/opensslv.h>
|
||||||
#include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
@@ -123,8 +124,9 @@ tls_shutdown(void) {
|
|||||||
REQUIRE(atomic_load(&init_done));
|
REQUIRE(atomic_load(&init_done));
|
||||||
REQUIRE(!atomic_load(&shut_done));
|
REQUIRE(!atomic_load(&shut_done));
|
||||||
|
|
||||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||||
|
OPENSSL_cleanup();
|
||||||
|
#else
|
||||||
CONF_modules_unload(1);
|
CONF_modules_unload(1);
|
||||||
OBJ_cleanup();
|
OBJ_cleanup();
|
||||||
EVP_cleanup();
|
EVP_cleanup();
|
||||||
|
|||||||
Reference in New Issue
Block a user