All of lore.kernel.org
 help / color / mirror / Atom feed
* [kirkstone][meta-networking][PATCH] net-snmp: fix memory leak
@ 2025-02-20  2:27 jinfeng.wang.cn
  0 siblings, 0 replies; 10+ messages in thread
From: jinfeng.wang.cn @ 2025-02-20  2:27 UTC (permalink / raw)
  To: openembedded-devel

From: Jinfeng Wang <jinfeng.wang.cn@windriver.com>

Backport patch [1] to fix memory leak by freeing tclist
[1] https://github.com/net-snmp/net-snmp/commit/4bd0d9a8a2860c2c46307aef5ee1ccc69f7e3b62

Signed-off-by: Jinfeng Wang <jinfeng.wang.cn@windriver.com>
---
 ...bs-fix-memory-leak-by-freeing-tclist.patch | 40 +++++++++++++++++++
 .../net-snmp/net-snmp_5.9.3.bb                |  1 +
 2 files changed, 41 insertions(+)
 create mode 100644 meta-networking/recipes-protocols/net-snmp/net-snmp/0001-unload_all_mibs-fix-memory-leak-by-freeing-tclist.patch

diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-unload_all_mibs-fix-memory-leak-by-freeing-tclist.patch b/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-unload_all_mibs-fix-memory-leak-by-freeing-tclist.patch
new file mode 100644
index 0000000000..3632881501
--- /dev/null
+++ b/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-unload_all_mibs-fix-memory-leak-by-freeing-tclist.patch
@@ -0,0 +1,40 @@
+From 4bd0d9a8a2860c2c46307aef5ee1ccc69f7e3b62 Mon Sep 17 00:00:00 2001
+From: JanSoundhouse <jan.sondhauss@wago.com>
+Date: Mon, 5 Sep 2022 11:25:58 +0200
+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.
+
+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 | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/snmplib/parse.c b/snmplib/parse.c
+index b3e2f3ae5c..71bdf75ff8 100644
+--- a/snmplib/parse.c
++++ b/snmplib/parse.c
+@@ -28,7 +28,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ SOFTWARE.
+ ******************************************************************/
+ /*
+- * Copyright � 2003 Sun Microsystems, Inc. All rights reserved.
++ * Copyright © 2003 Sun Microsystems, Inc. All rights reserved.
+  * Use is subject to license terms specified in the COPYING file
+  * distributed with the Net-SNMP package.
+  */
+@@ -4215,7 +4215,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
+
diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp_5.9.3.bb b/meta-networking/recipes-protocols/net-snmp/net-snmp_5.9.3.bb
index eb8e1599fb..88466c94b4 100644
--- a/meta-networking/recipes-protocols/net-snmp/net-snmp_5.9.3.bb
+++ b/meta-networking/recipes-protocols/net-snmp/net-snmp_5.9.3.bb
@@ -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"
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-04-09  3:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1825C99274128577.23135@lists.openembedded.org>
2025-03-10  7:01 ` [oe] [kirkstone][meta-networking][PATCH] net-snmp: fix memory leak Wang, Jinfeng (CN)
2025-03-10  9:29   ` Piotr L Lewicki
2025-03-10 10:56     ` Gyorgy Sarvari
2025-03-11  6:46       ` Wang, Jinfeng (CN)
2025-03-11  7:19         ` Piotr L Lewicki
2025-03-24 14:48           ` tim.dylla.ext
2025-03-24 14:51             ` tim.dylla.ext
     [not found]             ` <Groupsio.1.15989.1742827718915937909@lists.openembedded.org>
2025-03-24 16:21               ` [oe] " Piotr L Lewicki
2025-04-09  3:17               ` Wang, Jinfeng (CN)
2025-02-20  2:27 jinfeng.wang.cn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.