diff options
author | atishkov <a.tishkov@aladdin.ru> | 2023-07-21 11:36:37 +0300 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2023-07-25 17:02:20 +0200 |
commit | bc5d9cc8711e86d5c25b81c58dfae531536e61fc (patch) | |
tree | 0bb09b96c7fb44a05f7c56837d7076224f84e80d /crypto/x509 | |
parent | 8ae4b236347d82226b6d86e02a9717e6a51d58a0 (diff) |
get_cert_by_subject_ex(): Check result of X509_STORE_lock()
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21515)
Diffstat (limited to 'crypto/x509')
-rw-r--r-- | crypto/x509/by_dir.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c index 5d50592149..bb683a7795 100644 --- a/crypto/x509/by_dir.c +++ b/crypto/x509/by_dir.c @@ -348,7 +348,8 @@ static int get_cert_by_subject_ex(X509_LOOKUP *xl, X509_LOOKUP_TYPE type, * sorted and sorting the would result in O(n^2 log n) complexity. */ if (k > 0) { - X509_STORE_lock(xl->store_ctx); + if (!X509_STORE_lock(xl->store_ctx)) + goto finish; j = sk_X509_OBJECT_find(xl->store_ctx->objs, &stmp); tmp = sk_X509_OBJECT_value(xl->store_ctx->objs, j); X509_STORE_unlock(xl->store_ctx); @@ -420,9 +421,10 @@ static int get_cert_by_subject_ex(X509_LOOKUP *xl, X509_LOOKUP_TYPE type, finish: /* If we changed anything, resort the objects for faster lookup */ if (!sk_X509_OBJECT_is_sorted(xl->store_ctx->objs)) { - X509_STORE_lock(xl->store_ctx); - sk_X509_OBJECT_sort(xl->store_ctx->objs); - X509_STORE_unlock(xl->store_ctx); + if (X509_STORE_lock(xl->store_ctx)) { + sk_X509_OBJECT_sort(xl->store_ctx->objs); + X509_STORE_unlock(xl->store_ctx); + } } BUF_MEM_free(b); |