提交 58a8fc25 编写于 作者: M Matt Caswell

Fix the init cleanup order

There are internal dependencies between the various cleanup functions.
This re-orders things to try and get that right.
Reviewed-by: NRichard Levitte <levitte@openssl.org>
上级 b10cdcce
...@@ -460,25 +460,34 @@ void OPENSSL_cleanup(void) ...@@ -460,25 +460,34 @@ void OPENSSL_cleanup(void)
CRYPTO_THREAD_cleanup_local(&threadstopkey); CRYPTO_THREAD_cleanup_local(&threadstopkey);
#ifdef OPENSSL_INIT_DEBUG #ifdef OPENSSL_INIT_DEBUG
fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
"RAND_cleanup()\n");
fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
"CONF_modules_free()\n");
#ifndef OPENSSL_NO_ENGINE #ifndef OPENSSL_NO_ENGINE
fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: " fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
"ENGINE_cleanup()\n"); "ENGINE_cleanup()\n");
#endif #endif
fprintf(stderr, "OPENSSL_INIT: OPENSSL_INIT_library_stop: " fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
"CRYPTO_cleanup_all_ex_data()\n"); "CRYPTO_cleanup_all_ex_data()\n");
fprintf(stderr, "OPENSSL_INIT: OPENSSL_INIT_library_stop: " fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
"BIO_sock_cleanup()\n");
fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
"EVP_cleanup()\n"); "EVP_cleanup()\n");
fprintf(stderr, "OPENSSL_INIT: OPENSSL_INIT_library_stop: " fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
"CONF_modules_free()\n"); "OBJ_cleanup()\n");
fprintf(stderr, "OPENSSL_INIT: OPENSSL_INIT_library_stop: "
"RAND_cleanup()\n");
#endif #endif
/* /*
* Note that cleanup order is important. * Note that cleanup order is important:
* For example, ENGINEs use CRYPTO_EX_DATA and therefore, must be cleaned up * - RAND_cleanup could call an ENINGE's RAND cleanup function so must be
* before the ex data handlers are wiped in CRYPTO_cleanup_all_ex_data(). * called before ENGINE_cleanup()
*/ * - ENGINEs use CRYPTO_EX_DATA and therefore, must be cleaned up
* before the ex data handlers are wiped in CRYPTO_cleanup_all_ex_data().
* - CONF_modules_free() can end up in ENGINE code so must be called before
* ENGINE_cleanup()
*/
RAND_cleanup();
CONF_modules_free();
#ifndef OPENSSL_NO_ENGINE #ifndef OPENSSL_NO_ENGINE
ENGINE_cleanup(); ENGINE_cleanup();
#endif #endif
...@@ -486,8 +495,6 @@ void OPENSSL_cleanup(void) ...@@ -486,8 +495,6 @@ void OPENSSL_cleanup(void)
BIO_sock_cleanup(); BIO_sock_cleanup();
EVP_cleanup(); EVP_cleanup();
OBJ_cleanup(); OBJ_cleanup();
CONF_modules_free();
RAND_cleanup();
base_inited = 0; base_inited = 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册