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

Andy Polyakov appro at openssl.org
Fri Aug 3 07:01:23 UTC 2018


The branch OpenSSL_1_1_0-stable has been updated
       via  c700d1fe090acf3661d3948c25f489803f50a98b (commit)
       via  4e7ade969944a9e6923a48471efb910dfb5f4a3a (commit)
      from  24233a0f3c491919ee3a38e2567271ccc041ee1d (commit)


- Log -----------------------------------------------------------------
commit c700d1fe090acf3661d3948c25f489803f50a98b
Author: Andy Polyakov <appro at openssl.org>
Date:   Thu Aug 2 09:02:47 2018 +0200

    asn1/tasn_utl.c: fix logical error in asn1_do_lock.
    
    CRYPTO_atomic_add was assumed to return negative value on error, while
    it returns 0.
    
    Reviewed-by: Matt Caswell <matt at openssl.org>
    Reviewed-by: Paul Dale <paul.dale at oracle.com>
    (Merged from https://github.com/openssl/openssl/pull/6843)

commit 4e7ade969944a9e6923a48471efb910dfb5f4a3a
Author: Andy Polyakov <appro at openssl.org>
Date:   Thu Aug 2 08:59:48 2018 +0200

    Revert "asn1/tasn_utl.c: fix logical error in and overhaul asn1_do_lock."
    
    This reverts commit 24233a0f3c491919ee3a38e2567271ccc041ee1d.
    
    Reviewed-by: Matt Caswell <matt at openssl.org>
    Reviewed-by: Paul Dale <paul.dale at oracle.com>
    (Merged from https://github.com/openssl/openssl/pull/6843)

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

Summary of changes:
 crypto/asn1/tasn_utl.c | 35 ++++++++++++-----------------------
 1 file changed, 12 insertions(+), 23 deletions(-)

diff --git a/crypto/asn1/tasn_utl.c b/crypto/asn1/tasn_utl.c
index 22e853d..cad45a0 100644
--- a/crypto/asn1/tasn_utl.c
+++ b/crypto/asn1/tasn_utl.c
@@ -57,10 +57,8 @@ int asn1_set_choice_selector(ASN1_VALUE **pval, int value,
 int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it)
 {
     const ASN1_AUX *aux;
-    CRYPTO_REF_COUNT *lck;
+    int *lck, ret;
     CRYPTO_RWLOCK **lock;
-    int ret = -1;
-
     if ((it->itype != ASN1_ITYPE_SEQUENCE)
         && (it->itype != ASN1_ITYPE_NDEF_SEQUENCE))
         return 0;
@@ -69,34 +67,25 @@ int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it)
         return 0;
     lck = offset2ptr(*pval, aux->ref_offset);
     lock = offset2ptr(*pval, aux->ref_lock);
-
-    switch (op) {
-    case 0:
-        *lck = ret = 1;
+    if (op == 0) {
+        *lck = 1;
         *lock = CRYPTO_THREAD_lock_new();
         if (*lock == NULL) {
             ASN1err(ASN1_F_ASN1_DO_LOCK, ERR_R_MALLOC_FAILURE);
             return -1;
         }
-        break;
-    case 1:
-        if (!CRYPTO_UP_REF(lck, &ret, *lock))
-            return -1;
-        break;
-    case -1:
-        if (!CRYPTO_DOWN_REF(lck, &ret, *lock))
-            return -1;  /* failed */
+        return 1;
+    }
+    if (!CRYPTO_atomic_add(lck, op, &ret, *lock))
+        return -1;  /* failed */
 #ifdef REF_PRINT
-        fprintf(stderr, "%p:%4d:%s\n", it, ret, it->sname);
+    fprintf(stderr, "%p:%4d:%s\n", it, *lck, it->sname);
 #endif
-        REF_ASSERT_ISNT(ret < 0);
-        if (ret == 0) {
-            CRYPTO_THREAD_lock_free(*lock);
-            *lock = NULL;
-        }
-        break;
+    REF_ASSERT_ISNT(ret < 0);
+    if (ret == 0) {
+        CRYPTO_THREAD_lock_free(*lock);
+        *lock = NULL;
     }
-
     return ret;
 }
 


More information about the openssl-commits mailing list