From ea1c768e5dd8995f36d664da969f3afe815350a8 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sun, 23 Nov 2014 13:47:52 +0100 Subject: [PATCH] patches: 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 --- debian/changelog | 3 ++ debian/patches/00list | 1 + .../patches/bts750440_config_segfault.dpatch | 38 +++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100755 debian/patches/bts750440_config_segfault.dpatch diff --git a/debian/changelog b/debian/changelog index dc739f2..cb8bac3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 Sun, 23 Nov 2014 13:04:03 +0100 diff --git a/debian/patches/00list b/debian/patches/00list index 5046f3e..bb9acff 100644 --- a/debian/patches/00list +++ b/debian/patches/00list @@ -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 index 0000000..6a97fac --- /dev/null +++ b/debian/patches/bts750440_config_segfault.dpatch @@ -0,0 +1,38 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## bts750440_config_segfault.dpatch by Wilfried Goesgens +## +## 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; -- 2.30.2