mirror of https://github.com/openssl/openssl.git
Add locking to CRYPTO_secure_used
Coverity issue 1551719 noted CRYPTO_secure_used referenced a shared
variable without taking the appropriate read lock. Add that.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/22802)
(cherry picked from commit 7eae6ee0e5)
This commit is contained in:
parent
f7668698d1
commit
e934d62222
|
|
@ -260,11 +260,17 @@ int CRYPTO_secure_allocated(const void *ptr)
|
|||
|
||||
size_t CRYPTO_secure_used(void)
|
||||
{
|
||||
size_t ret = 0;
|
||||
|
||||
#ifndef OPENSSL_NO_SECURE_MEMORY
|
||||
return secure_mem_used;
|
||||
#else
|
||||
return 0;
|
||||
if (!CRYPTO_THREAD_read_lock(sec_malloc_lock))
|
||||
return 0;
|
||||
|
||||
ret = secure_mem_used;
|
||||
|
||||
CRYPTO_THREAD_unlock(sec_malloc_lock);
|
||||
#endif /* OPENSSL_NO_SECURE_MEMORY */
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t CRYPTO_secure_actual_size(void *ptr)
|
||||
|
|
|
|||
Loading…
Reference in New Issue