diff options
author | Rich Salz <rsalz@akamai.com> | 2021-02-18 15:31:56 -0500 |
---|---|---|
committer | Pauli <ppzgs1@gmail.com> | 2021-03-14 15:33:34 +1000 |
commit | cd3f8c1b11b0b9f4163bc8c62cbae38aec1b4030 (patch) | |
tree | de59d50b2ff9b2bd73a1ebf08eedf78d8ba44aa3 /crypto/ex_data.c | |
parent | f62846b703d163265176fe960ec7d087b4c3fa96 (diff) | |
download | openssl-cd3f8c1b11b0b9f4163bc8c62cbae38aec1b4030.tar.gz |
Always check CRYPTO_LOCK_{read,write}_lock
Some functions that lock things are void, so we just return early.
Also make ossl_namemap_empty return 0 on error. Updated the docs, and added
some code to ossl_namemap_stored() to handle the failure, and updated the
tests to allow for failure.
Fixes: #14230
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14238)
Diffstat (limited to 'crypto/ex_data.c')
-rw-r--r-- | crypto/ex_data.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/crypto/ex_data.c b/crypto/ex_data.c index 291e5a6498..da5b5b69ba 100644 --- a/crypto/ex_data.c +++ b/crypto/ex_data.c @@ -43,7 +43,8 @@ static EX_CALLBACKS *get_and_lock(OSSL_EX_DATA_GLOBAL *global, int class_index) return NULL; } - CRYPTO_THREAD_write_lock(global->ex_data_lock); + if (!CRYPTO_THREAD_write_lock(global->ex_data_lock)) + return NULL; ip = &global->ex_data[class_index]; return ip; } @@ -367,7 +368,8 @@ void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad) if (storage != NULL) f = storage[i]; else { - CRYPTO_THREAD_write_lock(global->ex_data_lock); + if (!CRYPTO_THREAD_write_lock(global->ex_data_lock)) + continue; f = sk_EX_CALLBACK_value(ip->meth, i); CRYPTO_THREAD_unlock(global->ex_data_lock); } |