mirror of
https://github.com/openssl/openssl.git
synced 2025-01-18 13:44:20 +08:00
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)
This commit is contained in:
parent
ff181969e2
commit
7eae6ee0e5
@ -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
Block a user