summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ea1c768)
raw | patch | inline | side by side (parent: ea1c768)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 23 Nov 2014 13:03:44 +0000 (14:03 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 23 Nov 2014 13:03:44 +0000 (14:03 +0100) |
Upstream fix for a memory leak in the SNMP plugin. Thanks to Marc Fournier for
reporting this.
Closes: #770688
reporting this.
Closes: #770688
debian/changelog | patch | blob | history | |
debian/patches/00list | patch | blob | history | |
debian/patches/bts770688_snmp_memleak.dpatch | [new file with mode: 0755] | patch | blob |
diff --git a/debian/changelog b/debian/changelog
index cb8bac328b33ab0cd0b2dda255750023dddc8695..12045897af05d0b816c15ebe57ced28dd88713fc 100644 (file)
--- a/debian/changelog
+++ b/debian/changelog
- Added bts750440_config_segfault: upstream fix for a segfault when
including empty config files; thanks to Bernd Zeimetz and Marc Fournier
for reporting this (Closes: #750440, #770685).
+ - Added bts770688_snmp_memleak: upstream fix for a memory leak in the
+ SNMP plugin; thanks to Marc Fournier for reporting this
+ (Closes: #770688).
-- Sebastian Harl <tokkee@debian.org> Sun, 23 Nov 2014 13:04:03 +0100
diff --git a/debian/patches/00list b/debian/patches/00list
index bb9acff916e2241f4b9fd9a35395e1fc7b639f23..51d49a0ec626c772a02d2a1243ffe5b56d5fb9f6 100644 (file)
--- a/debian/patches/00list
+++ b/debian/patches/00list
bts747093_lvm_segfault.dpatch
bts770683_curl_init.dpatch
bts750440_config_segfault.dpatch
+bts770688_snmp_memleak.dpatch
diff --git a/debian/patches/bts770688_snmp_memleak.dpatch b/debian/patches/bts770688_snmp_memleak.dpatch
--- /dev/null
@@ -0,0 +1,53 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## bts770688_snmp_memleak.dpatch by Pierre-Yves Ritschard <pyr@spootnik.org>
+## and Marc Fournier <marc.fournier@camptocamp.com>
+##
+## DP: Let snmp_synch_response deal with PDU freeing
+## DP:
+## DP: When reading from tables, upon errors the PDUs sent are already
+## DP: freed by snmp_synch_response since they are right after
+## DP: snmp_send is called.
+## DP:
+## DP: This commit syncs collectd's approach with other occurences of
+## DP: snmp_synch_response calls.
+## DP:
+## DP: There might be a few corner cases where we leak PDUs, but it
+## DP: is unclear how to check for those since we would need to
+## DP: have an indication that snmp_send was never called, which
+## DP: as far as I can tell is not possible.
+## DP:
+## DP: The potential for failure in snmp_send is rather low and will
+## DP: be easily spotted though, since when crafting invalid PDUs
+## DP: snmp send will constantly fail and since valid configurations
+## DP: can never leak memory.
+## DP:
+## DP: Upstream bug reports:
+## DP: https://github.com/collectd/collectd/issues/610
+## DP: https://github.com/collectd/collectd/issues/804
+
+@DPATCH@
+
+diff --git a/src/snmp.c b/src/snmp.c
+index ad81c89..7d340d1 100644
+--- a/src/snmp.c
++++ b/src/snmp.c
+@@ -1316,6 +1316,8 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data)
+ snmp_free_pdu (res);
+ res = NULL;
+
++ /* snmp_synch_response already freed our PDU */
++ req = NULL;
+ sfree (errstr);
+ csnmp_host_close_session (host);
+
+@@ -1437,6 +1439,10 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data)
+ snmp_free_pdu (res);
+ res = NULL;
+
++ if (req != NULL)
++ snmp_free_pdu (req);
++ req = NULL;
++
+ if (status == 0)
+ csnmp_dispatch_table (host, data, instance_list_head, value_list_head);
+