1 Star 0 Fork 39

luofeng14/rsyslog

forked from src-openEuler/rsyslog 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
backport-GNUTls-Driver-Fix-memory-leaks-in-gtlsInitC.patch 1.56 KB
一键复制 编辑 原始数据 按行查看 历史
From 0f06a850ced79244774734ed525b289f2930d9c7 Mon Sep 17 00:00:00 2001
From: Andre lorbach <alorbach@adiscon.com>
Date: Thu, 11 May 2023 16:49:11 +0200
Subject: [PATCH] [backport] GNUTls Driver: Fix memory leaks in gtlsInitCred
Missing CA Certificate or multiple Connections caused
a memory leak in pThis->xcred as it was allocated each time in
gtlsInitCred by gnutls_certificate_allocate_credentials
closes: https://github.com/rsyslog/rsyslog/issues/5135
---
Conflict:NA
Type:bugfix
Reference:https://github.com/rsyslog/rsyslog/commit/3401d687d2d5f9556165b53be79fbe4dc49b8c79
---
---
runtime/nsd_gtls.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/runtime/nsd_gtls.c b/runtime/nsd_gtls.c
index e003d85d3..91cffb500 100644
--- a/runtime/nsd_gtls.c
+++ b/runtime/nsd_gtls.c
@@ -711,7 +711,10 @@ gtlsInitCred(nsd_gtls_t *const pThis )
DEFiRet;
/* X509 stuff */
- CHKgnutls(gnutls_certificate_allocate_credentials(&pThis->xcred));
+ if (pThis->xcred == NULL) {
+ /* Allocate only ONCE */
+ CHKgnutls(gnutls_certificate_allocate_credentials(&pThis->xcred));
+ }
/* sets the trusted cas file */
cafile = (pThis->pszCAFile == NULL) ? glbl.GetDfltNetstrmDrvrCAF(runConf) : pThis->pszCAFile;
@@ -2277,7 +2280,12 @@ finalize_it:
if(pThis->bHaveSess) {
gnutls_deinit(pThis->sess);
pThis->bHaveSess = 0;
+ /* Free memory using gnutls api first*/
+ gnutls_certificate_free_credentials(pThis->xcred);
pThis->xcred = NULL;
+ /* Free other memory */
+ free(pThis->pszConnectHost);
+ pThis->pszConnectHost = NULL;
}
}
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/luofeng14/rsyslog.git
git@gitee.com:luofeng14/rsyslog.git
luofeng14
rsyslog
rsyslog
master

搜索帮助