1 Star 0 Fork 100

fly_fzc/openssl

forked from src-openEuler/openssl 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-Avoid-an-unneccessary-lock-if-we-didn-t-add-anything.patch 1.63 KB
一键复制 编辑 原始数据 按行查看 历史
From 00bea959ab580c78e00eb56780fec8d53dab054d Mon Sep 17 00:00:00 2001
From: Matt Caswell <[email protected]>
Date: Fri, 12 May 2023 15:52:07 +0100
Subject: [PATCH] Avoid an unneccessary lock if we didn't add anything to the
store
Partially fixes #20286
Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/20952)
(cherry picked from commit 50001e0e15d4a96213c2eea7c56f80087afa89fd)
---
crypto/x509/by_dir.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c
index 1bc397a847..97e6ea0ee1 100644
--- a/crypto/x509/by_dir.c
+++ b/crypto/x509/by_dir.c
@@ -348,12 +348,16 @@ static int get_cert_by_subject_ex(X509_LOOKUP *xl, X509_LOOKUP_TYPE type,
/*
* we have added it to the cache so now pull it out again
*/
- 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);
-
+ if (k > 0) {
+ 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);
+ } else {
+ j = -1;
+ tmp = NULL;
+ }
/*
* If a CRL, update the last file suffix added for this.
* We don't need to add an entry if k is 0 as this is the initial value.
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fly_fzc/openssl.git
[email protected]:fly_fzc/openssl.git
fly_fzc
openssl
openssl
master

搜索帮助