Code

Added debian/patches/snmp_memleak.dpatch.
authorSebastian Harl <sh@tokkee.org>
Wed, 17 Sep 2008 17:19:39 +0000 (19:19 +0200)
committerSebastian Harl <sh@tokkee.org>
Wed, 17 Sep 2008 17:19:39 +0000 (19:19 +0200)
Trivial upstream patch to fix a possible memory leak in the snmp plugin.

debian/changelog
debian/patches/00list
debian/patches/snmp_memleak.dpatch [new file with mode: 0755]

index afc5acf5b068c5fa46e8838958a98dd77f44643d..8d8d8fbf0cf68ff32452cb449b55f3f3a4649acd 100644 (file)
@@ -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 <sh@tokkee.org>  Wed, 17 Sep 2008 10:28:36 +0200
+ -- Sebastian Harl <sh@tokkee.org>  Wed, 17 Sep 2008 19:17:55 +0200
 
 collectd (4.4.2-1) unstable; urgency=low
 
index d2a82d98d7dcb5e4ef9db1b389fbde6470e3d70f..9b2db92184df6ebfe0b63fa4f1fa408ca5d140a6 100644 (file)
@@ -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 (executable)
index 0000000..e4def25
--- /dev/null
@@ -0,0 +1,59 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## snmp_memleak.dpatch by Florian Forster <octo@noris.net>
+##
+## 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);