14 Star 0 Fork 12

ocs-commit/openssl

forked from OpenCloudOS Stream/openssl 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
3732a8963d7aacde04f138204e235478609cba8a.patch 4.79 KB
一键复制 编辑 原始数据 按行查看 历史
ocs-bot 提交于 2024-12-26 16:05 . - Apply patches from rpm-tracker
From 3732a8963d7aacde04f138204e235478609cba8a Mon Sep 17 00:00:00 2001
From: Tomas Mraz <tomas@openssl.org>
Date: Wed, 7 Feb 2024 10:27:50 +0100
Subject: [PATCH] Fix memory leaks on error cases during drbg initializations
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/23503)
(cherry picked from commit cb4f7a6ee053e8c51cf3ac35fee333d1f25552c0)
---
providers/implementations/rands/drbg.c | 3 ++-
providers/implementations/rands/drbg_ctr.c | 5 +++--
providers/implementations/rands/drbg_hash.c | 3 ++-
providers/implementations/rands/drbg_hmac.c | 3 ++-
providers/implementations/rands/drbg_local.h | 1 +
5 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/providers/implementations/rands/drbg.c b/providers/implementations/rands/drbg.c
index e30836c53cabb..09edce8eb44b6 100644
--- a/providers/implementations/rands/drbg.c
+++ b/providers/implementations/rands/drbg.c
@@ -765,6 +765,7 @@ int ossl_drbg_enable_locking(void *vctx)
PROV_DRBG *ossl_rand_drbg_new
(void *provctx, void *parent, const OSSL_DISPATCH *p_dispatch,
int (*dnew)(PROV_DRBG *ctx),
+ void (*dfree)(void *vctx),
int (*instantiate)(PROV_DRBG *drbg,
const unsigned char *entropy, size_t entropylen,
const unsigned char *nonce, size_t noncelen,
@@ -844,7 +845,7 @@ PROV_DRBG *ossl_rand_drbg_new
return drbg;
err:
- ossl_rand_drbg_free(drbg);
+ dfree(drbg);
return NULL;
}
diff --git a/providers/implementations/rands/drbg_ctr.c b/providers/implementations/rands/drbg_ctr.c
index 451113c4d1620..988a08bf93635 100644
--- a/providers/implementations/rands/drbg_ctr.c
+++ b/providers/implementations/rands/drbg_ctr.c
@@ -581,7 +581,7 @@ static int drbg_ctr_init(PROV_DRBG *drbg)
EVP_CIPHER_CTX_free(ctr->ctx_ecb);
EVP_CIPHER_CTX_free(ctr->ctx_ctr);
ctr->ctx_ecb = ctr->ctx_ctr = NULL;
- return 0;
+ return 0;
}
static int drbg_ctr_new(PROV_DRBG *drbg)
@@ -602,7 +602,8 @@ static int drbg_ctr_new(PROV_DRBG *drbg)
static void *drbg_ctr_new_wrapper(void *provctx, void *parent,
const OSSL_DISPATCH *parent_dispatch)
{
- return ossl_rand_drbg_new(provctx, parent, parent_dispatch, &drbg_ctr_new,
+ return ossl_rand_drbg_new(provctx, parent, parent_dispatch,
+ &drbg_ctr_new, &drbg_ctr_free,
&drbg_ctr_instantiate, &drbg_ctr_uninstantiate,
&drbg_ctr_reseed, &drbg_ctr_generate);
}
diff --git a/providers/implementations/rands/drbg_hash.c b/providers/implementations/rands/drbg_hash.c
index 6deb0a29256b2..4acf9a9830e40 100644
--- a/providers/implementations/rands/drbg_hash.c
+++ b/providers/implementations/rands/drbg_hash.c
@@ -410,7 +410,8 @@ static int drbg_hash_new(PROV_DRBG *ctx)
static void *drbg_hash_new_wrapper(void *provctx, void *parent,
const OSSL_DISPATCH *parent_dispatch)
{
- return ossl_rand_drbg_new(provctx, parent, parent_dispatch, &drbg_hash_new,
+ return ossl_rand_drbg_new(provctx, parent, parent_dispatch,
+ &drbg_hash_new, &drbg_hash_free,
&drbg_hash_instantiate, &drbg_hash_uninstantiate,
&drbg_hash_reseed, &drbg_hash_generate);
}
diff --git a/providers/implementations/rands/drbg_hmac.c b/providers/implementations/rands/drbg_hmac.c
index e68465a78cd9c..571f5e6f7a3b5 100644
--- a/providers/implementations/rands/drbg_hmac.c
+++ b/providers/implementations/rands/drbg_hmac.c
@@ -296,7 +296,8 @@ static int drbg_hmac_new(PROV_DRBG *drbg)
static void *drbg_hmac_new_wrapper(void *provctx, void *parent,
const OSSL_DISPATCH *parent_dispatch)
{
- return ossl_rand_drbg_new(provctx, parent, parent_dispatch, &drbg_hmac_new,
+ return ossl_rand_drbg_new(provctx, parent, parent_dispatch,
+ &drbg_hmac_new, &drbg_hmac_free,
&drbg_hmac_instantiate, &drbg_hmac_uninstantiate,
&drbg_hmac_reseed, &drbg_hmac_generate);
}
diff --git a/providers/implementations/rands/drbg_local.h b/providers/implementations/rands/drbg_local.h
index 8bc5df89c2363..a2d1ef5307489 100644
--- a/providers/implementations/rands/drbg_local.h
+++ b/providers/implementations/rands/drbg_local.h
@@ -181,6 +181,7 @@ struct prov_drbg_st {
PROV_DRBG *ossl_rand_drbg_new
(void *provctx, void *parent, const OSSL_DISPATCH *parent_dispatch,
int (*dnew)(PROV_DRBG *ctx),
+ void (*dfree)(void *vctx),
int (*instantiate)(PROV_DRBG *drbg,
const unsigned char *entropy, size_t entropylen,
const unsigned char *nonce, size_t noncelen,
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ocs-commit/openssl.git
git@gitee.com:ocs-commit/openssl.git
ocs-commit
openssl
openssl
master

搜索帮助