Skip to content

Commit

Permalink
crypto_compat_free(): handle recent OpenSSL and LibreSSL
Browse files Browse the repository at this point in the history
  • Loading branch information
gperciva committed Oct 15, 2023
1 parent 2fd649a commit 36968e3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/crypto/crypto_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,23 @@ void
crypto_compat_free(void)
{

#if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER > 0x1010000fL
/* OpenSSL 1.1.0 and higher: do nothing; the library uses atexit(). */
#elif defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER > 0x3070100fL
/* LibreSSL 3.7.1 and higher. */
OPENSSL_cleanup();
#elif defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER > 0x3060000fL
/* LibreSSL 3.6.0 to 3.7.0. */
OPENSSL_cleanup();
CRYPTO_cleanup_all_ex_data();
#else
/* Easerlier versions of OpenSSL and LibreSSL. */

/* Free OpenSSL error queue. */
#if OPENSSL_VERSION_NUMBER < 0x10000000L
ERR_remove_state(0);
#elif OPENSSL_VERSION_NUMBER < 0x10100000L
ERR_remove_thread_state(NULL);
#else
/* Nothing needed for OpenSSL >= 1.1. */
#endif

/* Free OpenSSL error strings. */
Expand All @@ -274,4 +284,5 @@ crypto_compat_free(void)

/* A more general OpenSSL cleanup function. */
CRYPTO_cleanup_all_ex_data();
#endif
}

0 comments on commit 36968e3

Please sign in to comment.