[openssl-commits] [openssl] master update

Matt Caswell matt at openssl.org
Wed Feb 10 12:05:19 UTC 2016


The branch master has been updated
       via  deca5df2fb879aa8763c54ab230dc6da940da9d0 (commit)
      from  740b2b9a6cf31b02916a4d18f868e8a95934c083 (commit)


- Log -----------------------------------------------------------------
commit deca5df2fb879aa8763c54ab230dc6da940da9d0
Author: Matt Caswell <matt at openssl.org>
Date:   Wed Feb 10 09:47:51 2016 +0000

    If we've not been inited don't deinit
    
    If you call an explicit deinit when we've not been inited then a seg
    fault can occur. We should check that we've been inited before attempting
    to deinit.
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>

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

Summary of changes:
 crypto/init.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/crypto/init.c b/crypto/init.c
index 26021d9..3b55a43 100644
--- a/crypto/init.c
+++ b/crypto/init.c
@@ -537,6 +537,10 @@ void OPENSSL_INIT_library_stop(void)
 {
     OPENSSL_INIT_STOP *currhandler, *lasthandler;
 
+    /* If we've not been inited then no need to deinit */
+    if (!base_inited)
+        return;
+
     /*
      * Thread stop may not get automatically called by the thread library for
      * the very last thread in some situations, so call it directly.
@@ -613,24 +617,22 @@ void OPENSSL_INIT_library_stop(void)
         OPENSSL_INIT_ONCE_DYNAMIC_INIT(&load_crypto_strings);
     }
 
-    if (base_inited) {
 #ifdef OPENSSL_INIT_DEBUG
-        fprintf(stderr, "OPENSSL_INIT: OPENSSL_INIT_library_stop: "
-                        "CRYPTO_cleanup_all_ex_data()\n");
-        fprintf(stderr, "OPENSSL_INIT: OPENSSL_INIT_library_stop: "
-                        "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_INIT_library_stop: "
+                    "CRYPTO_cleanup_all_ex_data()\n");
+    fprintf(stderr, "OPENSSL_INIT: OPENSSL_INIT_library_stop: "
+                    "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");
 #endif
-        CRYPTO_cleanup_all_ex_data();
-        EVP_cleanup();
-        CONF_modules_free();
-        RAND_cleanup();
-        base_inited = 0;
-        OPENSSL_INIT_ONCE_DYNAMIC_INIT(&base);
-    }
+    CRYPTO_cleanup_all_ex_data();
+    EVP_cleanup();
+    CONF_modules_free();
+    RAND_cleanup();
+    base_inited = 0;
+    OPENSSL_INIT_ONCE_DYNAMIC_INIT(&base);
 }
 
 static const OPENSSL_INIT_SETTINGS *ossl_init_get_setting(


More information about the openssl-commits mailing list