diff -Nru collectd-5.4.0/debian/changelog collectd-5.4.0/debian/changelog --- collectd-5.4.0/debian/changelog 2016-04-06 15:38:13.000000000 +0200 +++ collectd-5.4.0/debian/changelog 2016-04-06 15:38:14.000000000 +0200 @@ -1,3 +1,12 @@ +collectd (5.4.0-3ubuntu2.2) trusty; urgency=medium + + * debian/patches: + - Added bts770688_snmp_memleak: backport of upstream fix for a memory leak in + the SNMP plugin, which is included in 5.4.1-6 unstable; + thanks to Marc Fournier for reporting this. + + -- Akiko Kanno Wed, 06 Apr 2016 15:12:55 +0200 + collectd (5.4.0-3ubuntu2.1) trusty; urgency=medium * debian/patches: diff -Nru collectd-5.4.0/debian/patches/00list collectd-5.4.0/debian/patches/00list --- collectd-5.4.0/debian/patches/00list 2016-04-06 15:38:13.000000000 +0200 +++ collectd-5.4.0/debian/patches/00list 2016-04-06 15:38:14.000000000 +0200 @@ -6,3 +6,4 @@ ppc64el.dpatch libperl-linkage.dpatch swap_in_openvz.dpatch +bts770688_snmp_memleak.dpatch diff -Nru collectd-5.4.0/debian/patches/bts770688_snmp_memleak.dpatch collectd-5.4.0/debian/patches/bts770688_snmp_memleak.dpatch --- collectd-5.4.0/debian/patches/bts770688_snmp_memleak.dpatch 1970-01-01 01:00:00.000000000 +0100 +++ collectd-5.4.0/debian/patches/bts770688_snmp_memleak.dpatch 2016-04-06 15:38:14.000000000 +0200 @@ -0,0 +1,53 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## bts770688_snmp_memleak.dpatch by Pierre-Yves Ritschard +## and Marc Fournier +## +## 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); +