net-snmp: fix memory leak

Backport patch [1] to fix memory leak by freeing tclist
[1] 4bd0d9a8a2

Signed-off-by: Jinfeng Wang <jinfeng.wang.cn@windriver.com>
This commit is contained in:
Jinfeng Wang 2025-04-09 11:13:07 +08:00 committed by Armin Kuster
parent 77e91fceec
commit e42549cef3
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,32 @@
From 606e2cbb2d607820345aa20d4095613b1f563a08 Mon Sep 17 00:00:00 2001
From: Jinfeng Wang <jinfeng.wang.cn@windriver.com>
Date: Wed, 9 Apr 2025 09:24:45 +0800
Subject: [PATCH] unload_all_mibs: fix memory leak by freeing tclist
tclist is always allocated in netsnmp_init_mib_internals, when doing multiple init_snmp("")/snmp_shutdown("") this memory is never free'd.
Remove the special character in the origin commit.
Upstream-Status: Backport [https://github.com/net-snmp/net-snmp/commit/4bd0d9a8a2860c2c46307aef5ee1ccc69f7e3b62]
Signed-off-by: Jinfeng Wang <jinfeng.wang.cn@windriver.com>
---
snmplib/parse.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/snmplib/parse.c b/snmplib/parse.c
index 9406f4f88..2f9a20175 100644
--- a/snmplib/parse.c
+++ b/snmplib/parse.c
@@ -4225,7 +4225,8 @@ unload_all_mibs(void)
if (ptc->description)
free(ptc->description);
}
- memset(tclist, 0, tc_alloc * sizeof(struct tc));
+ SNMP_FREE(tclist);
+ tc_alloc = 0;
memset(buckets, 0, sizeof(buckets));
memset(nbuckets, 0, sizeof(nbuckets));
--
2.34.1

View File

@ -27,6 +27,7 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/net-snmp/net-snmp-${PV}.tar.gz \
file://reproducibility-have-printcap.patch \
file://0001-ac_add_search_path.m4-keep-consistent-between-32bit.patch \
file://CVE-2022-44792-CVE-2022-44793.patch \
file://0001-unload_all_mibs-fix-memory-leak-by-freeing-tclist.patch \
"
SRC_URI[sha256sum] = "2097f29b7e1bf3f1300b4bae52fa2308d0bb8d5d3998dbe02f9462a413a2ef0a"