aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Wujek <dev_public@wujek.eu>2020-12-21 11:25:34 +0000
committerGravatar Peter Korsgaard <peter@korsgaard.com>2020-12-24 09:36:54 +0100
commitec6f098e715182c94d0d1e2b5fa6c98494cd120d (patch)
treedc626f41644f329cc89c299043e791f144c223c3
parent478919b1a0cd176f7db40ba44d434f2f36e46c85 (diff)
downloadbuildroot-ec6f098e715182c94d0d1e2b5fa6c98494cd120d.tar.gz
buildroot-ec6f098e715182c94d0d1e2b5fa6c98494cd120d.tar.bz2
package/netsnmp: fix memory leak in IP-MIB when running without IPv6
In a Linux system without IPv6 support (or booted with "ipv6.disable=1") file /proc/net/snmp6 is not present. If such file is not present an allocated memory is not freed. Memory leak occurs even without snmp queries. Problem seen at least since netsnmp 5.7.3 (probably even v5.6.1). Patch backported from netsnmp 5.9, where the problem does not appear any more. Signed-off-by: Adam Wujek <dev_public@wujek.eu> Signed-off-by: Peter Korsgaard <peter@korsgaard.com> (cherry picked from commit 5e6f6e074508ece2207b02545a8ede5a296978c9) Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
-rw-r--r--package/netsnmp/0006-IP-MIB-Linux-Fix-a-memory-leak-in-an-error-path.patch37
1 files changed, 37 insertions, 0 deletions
diff --git a/package/netsnmp/0006-IP-MIB-Linux-Fix-a-memory-leak-in-an-error-path.patch b/package/netsnmp/0006-IP-MIB-Linux-Fix-a-memory-leak-in-an-error-path.patch
new file mode 100644
index 0000000000..fb68e175e5
--- /dev/null
+++ b/package/netsnmp/0006-IP-MIB-Linux-Fix-a-memory-leak-in-an-error-path.patch
@@ -0,0 +1,37 @@
+From 7c073e3a1b736689135fd2ed44ede5b83790bd37 Mon Sep 17 00:00:00 2001
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Mon, 26 Aug 2019 18:32:08 -0700
+Subject: IP-MIB, Linux: Fix a memory leak in an error path
+
+When a Linux system is booted with "ipv6.disable=1" in the kernel command
+line, the file "/proc/net/snmp6" is not created. Fix the memory leak in
+_systemstats_v6_load_systemstats() that is triggered with IPv6 disabled.
+
+See also https://sourceforge.net/p/net-snmp/bugs/2976/.
+
+Reported-by: Mark E Rusk <marker55@users.sourceforge.net>
+---
+ agent/mibgroup/ip-mib/data_access/systemstats_linux.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/agent/mibgroup/ip-mib/data_access/systemstats_linux.c b/agent/mibgroup/ip-mib/data_access/systemstats_linux.c
+index e28ff93..f68d122 100644
+--- a/agent/mibgroup/ip-mib/data_access/systemstats_linux.c
++++ b/agent/mibgroup/ip-mib/data_access/systemstats_linux.c
+@@ -560,10 +560,12 @@ _systemstats_v6_load_systemstats(netsnmp_container* container, u_int load_flags)
+ * try to open file. If we can't, that's ok - maybe the module hasn't
+ * been loaded yet.
+ */
+- if (!(devin = fopen(filename, "r"))) {
++ devin = fopen(filename, "r");
++ if (!devin) {
+ DEBUGMSGTL(("access:systemstats",
+ "Failed to load Systemstats Table (linux1), cannot open %s\n",
+ filename));
++ netsnmp_access_systemstats_entry_free(entry);
+ return 0;
+ }
+
+--
+2.7.4
+