[openssl-commits] [openssl] master update

Matt Caswell matt at openssl.org
Mon Mar 14 10:57:42 UTC 2016


The branch master has been updated
       via  58a8fc25d73d8558df25d998f85d4714fbbe74ac (commit)
       via  b10cdcce005780d9a5ac0398fb0cb4194c0d991b (commit)
      from  a87c159f19e998bba660ceba9d01c5fc58bfa60b (commit)


- Log -----------------------------------------------------------------
commit 58a8fc25d73d8558df25d998f85d4714fbbe74ac
Author: Matt Caswell <matt at openssl.org>
Date:   Mon Mar 14 10:34:59 2016 +0000

    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: Richard Levitte <levitte at openssl.org>

commit b10cdcce005780d9a5ac0398fb0cb4194c0d991b
Author: Matt Caswell <matt at openssl.org>
Date:   Mon Mar 14 10:26:28 2016 +0000

    Add some missing cleanup calls to de-init
    
    OBJ_cleanup() doesn't always get called from EVP_cleanup() so needs to be
    explicitly called in de-init. Also BIO_sock_cleanup() also needs to be
    called.
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 crypto/init.c | 37 +++++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/crypto/init.c b/crypto/init.c
index d50d7f1..8cf7271 100644
--- a/crypto/init.c
+++ b/crypto/init.c
@@ -460,32 +460,41 @@ void OPENSSL_cleanup(void)
     CRYPTO_THREAD_cleanup_local(&threadstopkey);
 
 #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
     fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
                     "ENGINE_cleanup()\n");
 #endif
-    fprintf(stderr, "OPENSSL_INIT: OPENSSL_INIT_library_stop: "
+    fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
                     "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");
-    fprintf(stderr, "OPENSSL_INIT: OPENSSL_INIT_library_stop: "
-                    "CONF_modules_free()\n");
-    fprintf(stderr, "OPENSSL_INIT: OPENSSL_INIT_library_stop: "
-                    "RAND_cleanup()\n");
-
+    fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
+                    "OBJ_cleanup()\n");
 #endif
-/*
- * Note that cleanup order is important.
- * For example, ENGINEs use CRYPTO_EX_DATA and therefore, must be cleaned up
- * before the ex data handlers are wiped in CRYPTO_cleanup_all_ex_data().
- */
+    /*
+     * Note that cleanup order is important:
+     * - RAND_cleanup could call an ENINGE's RAND cleanup function so must be
+     * 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
     ENGINE_cleanup();
 #endif
     CRYPTO_cleanup_all_ex_data();
+    BIO_sock_cleanup();
     EVP_cleanup();
-    CONF_modules_free();
-    RAND_cleanup();
+    OBJ_cleanup();
     base_inited = 0;
 }
 


More information about the openssl-commits mailing list