From b4e044dbd6799f64f2f7741da642f5d0b843300d Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Wed, 17 Sep 2008 19:19:39 +0200 Subject: [PATCH] Added debian/patches/snmp_memleak.dpatch. Trivial upstream patch to fix a possible memory leak in the snmp plugin. --- debian/changelog | 4 +- debian/patches/00list | 1 + debian/patches/snmp_memleak.dpatch | 59 ++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100755 debian/patches/snmp_memleak.dpatch diff --git a/debian/changelog b/debian/changelog index afc5acf..8d8d8fb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,8 +8,10 @@ collectd (4.4.2-2) unstable; urgency=low fix a typo in the libstatgrab code of the memory plugin. * Added debian/patches/collectd_memleak.dpatch - trivial upstream patch to fix a possible memory leak. + * Added debian/patches/snmp_memleak.dpatch - trivial upstream patch to fix a + possible memory leak in the snmp plugin. - -- Sebastian Harl Wed, 17 Sep 2008 10:28:36 +0200 + -- Sebastian Harl Wed, 17 Sep 2008 19:17:55 +0200 collectd (4.4.2-1) unstable; urgency=low diff --git a/debian/patches/00list b/debian/patches/00list index d2a82d9..9b2db92 100644 --- a/debian/patches/00list +++ b/debian/patches/00list @@ -3,4 +3,5 @@ collection_conf_path.dpatch myplugin_strcpy.dpatch memory_libstatgrab.dpatch collectd_memleak.dpatch +snmp_memleak.dpatch diff --git a/debian/patches/snmp_memleak.dpatch b/debian/patches/snmp_memleak.dpatch new file mode 100755 index 0000000..e4def25 --- /dev/null +++ b/debian/patches/snmp_memleak.dpatch @@ -0,0 +1,59 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## snmp_memleak.dpatch by Florian Forster +## +## DP: Fix a possible memory leak in the snmp plugin: The SNMP result object +## DP: was not freed when `csnmp_instance_list_add' failed. +## DP: (This is upstream Git commit 0109e3c1f3a515ed716ddbdc261e0ed2e3f8e640) + +@DPATCH@ + +diff a/src/snmp.c b/src/snmp.c +--- a/src/snmp.c ++++ b/src/snmp.c +@@ -1120,10 +1120,6 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data) + vb = res->variables; + if (vb == NULL) + { +- if (res != NULL) +- snmp_free_pdu (res); +- res = NULL; +- + status = -1; + break; + } +@@ -1132,10 +1128,7 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data) + * subtree */ + if (csnmp_check_res_left_subtree (host, data, res) != 0) + { +- if (res != NULL) +- snmp_free_pdu (res); +- res = NULL; +- ++ status = 0; + break; + } + +@@ -1157,11 +1150,7 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data) + (vb != NULL) && (vb->next_variable != NULL); + vb = vb->next_variable) + /* do nothing */; +- if (vb == NULL) +- { +- status = -1; +- break; +- } ++ assert (vb != NULL); + + /* Copy OID to oid_list[data->values_len] */ + memcpy (oid_list[data->values_len].oid, vb->name, +@@ -1224,6 +1213,10 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data) + res = NULL; + } /* while (status == 0) */ + ++ if (res != NULL) ++ snmp_free_pdu (res); ++ res = NULL; ++ + if (status == 0) + csnmp_dispatch_table (host, data, instance_list, value_table); + -- 2.30.2