[openssl-commits] [openssl] OpenSSL_1_1_0-stable update

bernd.edlinger at hotmail.de bernd.edlinger at hotmail.de
Fri Jun 15 15:33:07 UTC 2018


The branch OpenSSL_1_1_0-stable has been updated
       via  1eeb882e3309eac9248e6b998fcb8a0fef42126b (commit)
      from  0c27d793745c7837b13646302b6890a556b7017a (commit)


- Log -----------------------------------------------------------------
commit 1eeb882e3309eac9248e6b998fcb8a0fef42126b
Author: Bernd Edlinger <bernd.edlinger at hotmail.de>
Date:   Tue Apr 3 23:47:10 2018 +0200

    Backport of commit 6b49b30811f4afa0340342af9400b8d0357b5291
    
    Prevent a possible recursion in ERR_get_state and fix the problem that
    was pointed out in commit aef84bb4efbddfd95d042f3f5f1d362ed7d4faeb
    differently.
    
    Fixes: #6493
    
    Reviewed-by: Matt Caswell <matt at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/6494)

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

Summary of changes:
 crypto/err/err.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/crypto/err/err.c b/crypto/err/err.c
index 06f16d3..dfbf5cd 100644
--- a/crypto/err/err.c
+++ b/crypto/err/err.c
@@ -662,24 +662,23 @@ ERR_STATE *ERR_get_state(void)
     if (!RUN_ONCE(&err_init, err_do_init))
         return NULL;
 
-    /*
-     * If base OPENSSL_init_crypto() hasn't been called yet, be sure to call
-     * it now to avoid state to be doubly allocated and thereby leak memory.
-     * Needed on any platform that doesn't define OPENSSL_USE_NODELETE.
-     */
-    if (!OPENSSL_init_crypto(0, NULL))
-        return NULL;
-
     state = CRYPTO_THREAD_get_local(&err_thread_local);
+    if (state == (ERR_STATE*)-1)
+        return NULL;
 
     if (state == NULL) {
-        state = OPENSSL_zalloc(sizeof(*state));
-        if (state == NULL)
+        if (!CRYPTO_THREAD_set_local(&err_thread_local, (ERR_STATE*)-1))
+            return NULL;
+
+        if ((state = OPENSSL_zalloc(sizeof(*state))) == NULL) {
+            CRYPTO_THREAD_set_local(&err_thread_local, NULL);
             return NULL;
+        }
 
         if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE)
-            || !CRYPTO_THREAD_set_local(&err_thread_local, state)) {
+                || !CRYPTO_THREAD_set_local(&err_thread_local, state)) {
             ERR_STATE_free(state);
+            CRYPTO_THREAD_set_local(&err_thread_local, NULL);
             return NULL;
         }
 


More information about the openssl-commits mailing list