Code

patches: Added bts750440_config_segfault.
authorSebastian Harl <sh@tokkee.org>
Sun, 23 Nov 2014 12:47:52 +0000 (13:47 +0100)
committerSebastian Harl <sh@tokkee.org>
Sun, 23 Nov 2014 12:47:52 +0000 (13:47 +0100)
Upstream fix for a segfault when including empty config files. Thanks to Bernd
Zeimetz and Marc Fournier for reporting this.

Closes: #750440, #770685
debian/changelog
debian/patches/00list
debian/patches/bts750440_config_segfault.dpatch [new file with mode: 0755]

index dc739f29ddcf4c51724e384c6fb1c0ee63d0b1a2..cb8bac328b33ab0cd0b2dda255750023dddc8695 100644 (file)
@@ -10,6 +10,9 @@ collectd (5.4.1-6) UNRELEASED; urgency=medium
     - Added bts770683_curl_init: upstream fix for a segfault in plugins using
       libcurl caused by concurrent memory access; thanks to Marc Fournier for
       reporting this (Closes: #770683, cf. #735173).
+    - 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).
 
  -- Sebastian Harl <tokkee@debian.org>  Sun, 23 Nov 2014 13:04:03 +0100
 
index 5046f3e3482a4cb901bdf09fe6bc45f3a24fb613..bb9acff916e2241f4b9fd9a35395e1fc7b639f23 100644 (file)
@@ -7,3 +7,4 @@ bts559801_plugin_find_fix.dpatch
 bts770681_riemann_ack.dpatch
 bts747093_lvm_segfault.dpatch
 bts770683_curl_init.dpatch
+bts750440_config_segfault.dpatch
diff --git a/debian/patches/bts750440_config_segfault.dpatch b/debian/patches/bts750440_config_segfault.dpatch
new file mode 100755 (executable)
index 0000000..6a97fac
--- /dev/null
@@ -0,0 +1,38 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## bts750440_config_segfault.dpatch by Wilfried Goesgens <dothebart@citadel.org>
+##
+## DP: Fixed a segfault when handling/including empty config files.
+## DP:
+## DP: Correctly handle the case of empty "children" nodes.
+## DP:
+## DP: Upstream bug report:
+## DP: https://github.com/collectd/collectd/issues/638
+
+@DPATCH@
+
+diff a/src/configfile.c b/src/configfile.c
+--- a/src/configfile.c
++++ b/src/configfile.c
+@@ -414,6 +414,12 @@ static int cf_ci_replace_child (oconfig_item_t *dst, oconfig_item_t *src,
+       /* Resize the memory containing the children to be big enough to hold
+        * all children. */
++      if (dst->children_num + src->children_num - 1 == 0)
++      {
++              dst->children_num = 0;
++              return (0);
++      }
++
+       temp = (oconfig_item_t *) realloc (dst->children,
+                       sizeof (oconfig_item_t)
+                       * (dst->children_num + src->children_num - 1));
+@@ -514,7 +520,8 @@ static int cf_include_all (oconfig_item_t *root, int depth)
+                       continue;
+               /* Now replace the i'th child in `root' with `new'. */
+-              cf_ci_replace_child (root, new, i);
++              if (cf_ci_replace_child (root, new, i) < 0)
++                      return (-1);
+               /* ... and go back to the new i'th child. */
+               --i;