Make the lock in CRYPTO_secure_allocated() a read lock
authorPauli <pauli@openssl.org>
Tue, 6 Apr 2021 02:24:06 +0000 (12:24 +1000)
committerPauli <pauli@openssl.org>
Wed, 7 Apr 2021 13:28:07 +0000 (23:28 +1000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14775)

crypto/mem_sec.c

index ebc0e557b5c6f08d1eab6677a08ca988e694181b..276c1165c103ef0089e92519ef0b830e5d367f88 100644 (file)
@@ -212,7 +212,7 @@ int CRYPTO_secure_allocated(const void *ptr)
 
     if (!secure_mem_initialized)
         return 0;
-    if (!CRYPTO_THREAD_write_lock(sec_malloc_lock))
+    if (!CRYPTO_THREAD_read_lock(sec_malloc_lock))
         return 0;
     ret = sh_allocated(ptr);
     CRYPTO_THREAD_unlock(sec_malloc_lock);