From a708e85236d17abaf16da4c455af8a776ad2f7b9 Mon Sep 17 00:00:00 2001 From: George Kadianakis Date: Tue, 22 Nov 2011 15:11:40 +0100 Subject: [PATCH 1/2] Move crypto_global_cleanup() to the bottom of crypto.c. --- src/common/crypto.c | 63 +++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/src/common/crypto.c b/src/common/crypto.c index ebaa0122fd..a9d8b04e60 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -291,37 +291,6 @@ crypto_thread_cleanup(void) ERR_remove_state(0); } -/** Uninitialize the crypto library. Return 0 on success, -1 on failure. - */ -int -crypto_global_cleanup(void) -{ - EVP_cleanup(); - ERR_remove_state(0); - ERR_free_strings(); - -#ifndef DISABLE_ENGINES - ENGINE_cleanup(); -#endif - - CONF_modules_unload(1); - CRYPTO_cleanup_all_ex_data(); -#ifdef TOR_IS_MULTITHREADED - if (_n_openssl_mutexes) { - int n = _n_openssl_mutexes; - tor_mutex_t **ms = _openssl_mutexes; - int i; - _openssl_mutexes = NULL; - _n_openssl_mutexes = 0; - for (i=0;i Date: Tue, 22 Nov 2011 15:14:59 +0100 Subject: [PATCH 2/2] Free the global DH parameters in crypto_global_cleanup(). --- src/common/crypto.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/common/crypto.c b/src/common/crypto.c index a9d8b04e60..62b0bcec6c 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -3069,6 +3069,13 @@ crypto_global_cleanup(void) ERR_remove_state(0); ERR_free_strings(); + if (dh_param_p) + BN_free(dh_param_p); + if (dh_param_p_tls) + BN_free(dh_param_p_tls); + if (dh_param_g) + BN_free(dh_param_g); + #ifndef DISABLE_ENGINES ENGINE_cleanup(); #endif