From 6404d064b8012a2c353603a3b3effa6289313d61 Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Wed, 16 Aug 2023 16:29:01 +0200 Subject: [PATCH] ossl_x509_store_ctx_get_by_subject(): Check return value of X509_STORE_lock() Fixes Coverity 1539148 Reviewed-by: Matt Caswell Reviewed-by: Hugo Landau (Merged from https://github.com/openssl/openssl/pull/21755) --- crypto/x509/x509_lu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crypto/x509/x509_lu.c b/crypto/x509/x509_lu.c index 08b8425bbe4..c639b54a543 100644 --- a/crypto/x509/x509_lu.c +++ b/crypto/x509/x509_lu.c @@ -339,7 +339,8 @@ static int ossl_x509_store_ctx_get_by_subject(const X509_STORE_CTX *ctx, if (!sk_X509_OBJECT_is_sorted(store->objs)) { X509_STORE_unlock(store); /* Take a write lock instead of a read lock */ - X509_STORE_lock(store); + if (!X509_STORE_lock(store)) + return 0; /* * Another thread might have sorted it in the meantime. But if so, * sk_X509_OBJECT_sort() exits early. -- 2.47.3