summaryrefslogtreecommitdiffstats
path: root/crypto/evp/names.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2021-02-19 17:03:43 +0000
committerPauli <ppzgs1@gmail.com>2021-02-25 08:37:22 +1000
commitd84f5515faf3fe00ed5eeca7e7b8b041be863e90 (patch)
treeb2e8245e0a152f16b5bb2c5260e47781a6261c9d /crypto/evp/names.c
parent6be27456e1346121b1fed797e92353733b59e16e (diff)
Don't hold a lock when calling a callback in ossl_namemap_doall_names
We don't want to hold a read lock when calling a user supplied callback. That callback could do anything so the risk of a deadlock is high. Instead we collect all the names first inside the read lock, and then subsequently call the user callback outside the read lock. Fixes #14225 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14250)
Diffstat (limited to 'crypto/evp/names.c')
-rw-r--r--crypto/evp/names.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/crypto/evp/names.c b/crypto/evp/names.c
index cb59813857..97fd1b8302 100644
--- a/crypto/evp/names.c
+++ b/crypto/evp/names.c
@@ -98,7 +98,8 @@ const EVP_CIPHER *evp_get_cipherbyname_ex(OSSL_LIB_CTX *libctx,
if (id == 0)
return NULL;
- ossl_namemap_doall_names(namemap, id, cipher_from_name, &cp);
+ if (!ossl_namemap_doall_names(namemap, id, cipher_from_name, &cp))
+ return NULL;
return cp;
}
@@ -143,7 +144,8 @@ const EVP_MD *evp_get_digestbyname_ex(OSSL_LIB_CTX *libctx, const char *name)
if (id == 0)
return NULL;
- ossl_namemap_doall_names(namemap, id, digest_from_name, &dp);
+ if (!ossl_namemap_doall_names(namemap, id, digest_from_name, &dp))
+ return NULL;
return dp;
}