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/store | |
parent | f62846b703d163265176fe960ec7d087b4c3fa96 (diff) |
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/store')
-rw-r--r-- | crypto/store/store_register.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/crypto/store/store_register.c b/crypto/store/store_register.c index 51bd591790..5049671f52 100644 --- a/crypto/store/store_register.c +++ b/crypto/store/store_register.c @@ -194,7 +194,8 @@ int ossl_store_register_loader_int(OSSL_STORE_LOADER *loader) ERR_raise(ERR_LIB_OSSL_STORE, ERR_R_MALLOC_FAILURE); return 0; } - CRYPTO_THREAD_write_lock(registry_lock); + if (!CRYPTO_THREAD_write_lock(registry_lock)) + return 0; if (ossl_store_register_init() && (lh_OSSL_STORE_LOADER_insert(loader_register, loader) != NULL @@ -226,7 +227,8 @@ const OSSL_STORE_LOADER *ossl_store_get0_loader_int(const char *scheme) ERR_raise(ERR_LIB_OSSL_STORE, ERR_R_MALLOC_FAILURE); return NULL; } - CRYPTO_THREAD_write_lock(registry_lock); + if (!CRYPTO_THREAD_write_lock(registry_lock)) + return NULL; if (!ossl_store_register_init()) ERR_raise(ERR_LIB_OSSL_STORE, ERR_R_INTERNAL_ERROR); @@ -255,7 +257,8 @@ OSSL_STORE_LOADER *ossl_store_unregister_loader_int(const char *scheme) ERR_raise(ERR_LIB_OSSL_STORE, ERR_R_MALLOC_FAILURE); return NULL; } - CRYPTO_THREAD_write_lock(registry_lock); + if (!CRYPTO_THREAD_write_lock(registry_lock)) + return NULL; if (!ossl_store_register_init()) ERR_raise(ERR_LIB_OSSL_STORE, ERR_R_INTERNAL_ERROR); |