summaryrefslogtreecommitdiffstats
path: root/crypto/err
diff options
context:
space:
mode:
authorRich Salz <rsalz@akamai.com>2021-02-18 15:31:56 -0500
committerPauli <ppzgs1@gmail.com>2021-03-14 15:33:34 +1000
commitcd3f8c1b11b0b9f4163bc8c62cbae38aec1b4030 (patch)
treede59d50b2ff9b2bd73a1ebf08eedf78d8ba44aa3 /crypto/err
parentf62846b703d163265176fe960ec7d087b4c3fa96 (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/err')
-rw-r--r--crypto/err/err.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/crypto/err/err.c b/crypto/err/err.c
index a8bde92674..23836b844b 100644
--- a/crypto/err/err.c
+++ b/crypto/err/err.c
@@ -176,7 +176,8 @@ static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *d)
{
ERR_STRING_DATA *p = NULL;
- CRYPTO_THREAD_read_lock(err_string_lock);
+ if (!CRYPTO_THREAD_read_lock(err_string_lock))
+ return NULL;
p = lh_ERR_STRING_DATA_retrieve(int_error_hash, d);
CRYPTO_THREAD_unlock(err_string_lock);
@@ -238,7 +239,8 @@ static void err_patch(int lib, ERR_STRING_DATA *str)
*/
static int err_load_strings(const ERR_STRING_DATA *str)
{
- CRYPTO_THREAD_write_lock(err_string_lock);
+ if (!CRYPTO_THREAD_write_lock(err_string_lock))
+ return 0;
for (; str->error; str++)
(void)lh_ERR_STRING_DATA_insert(int_error_hash,
(ERR_STRING_DATA *)str);
@@ -281,7 +283,8 @@ int ERR_unload_strings(int lib, ERR_STRING_DATA *str)
if (!RUN_ONCE(&err_string_init, do_err_strings_init))
return 0;
- CRYPTO_THREAD_write_lock(err_string_lock);
+ if (!CRYPTO_THREAD_write_lock(err_string_lock))
+ return 0;
/*
* We don't need to ERR_PACK the lib, since that was done (to
* the table) when it was loaded.
@@ -728,7 +731,8 @@ int ERR_get_next_error_library(void)
if (!RUN_ONCE(&err_string_init, do_err_strings_init))
return 0;
- CRYPTO_THREAD_write_lock(err_string_lock);
+ if (!CRYPTO_THREAD_write_lock(err_string_lock))
+ return 0;
ret = int_err_library_number++;
CRYPTO_THREAD_unlock(err_string_lock);
return ret;