From e7d507f848a0b271aa9dc81b76fc6565e7ecd80e Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Thu, 28 May 2009 16:28:27 +0200 Subject: [PATCH] patches: Added include_empty_files.dpatch. This is an upstream patch to fix the inclusion of empty configuration files, thanks to Alexander Wirt for reporting this. --- debian/changelog | 5 ++- debian/patches/00list | 1 + debian/patches/include_empty_files.dpatch | 54 +++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100755 debian/patches/include_empty_files.dpatch diff --git a/debian/changelog b/debian/changelog index 0939ea5..d0a87d3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,9 @@ collectd (4.6.2-2) unstable; urgency=low - Added ntpd_type_pun_fix.dpatch - upstream patch to fix dereferencing of a type-punned pointer identified by GCC 4.4, thanks to Martin Michlmayr for reporting this (Closes: #526667). + - Added include_empty_files.dpatch - upstream patch to fix the inclusion + of empty configuration files, thanks to Alexander Wirt for reporting + this. * debian/collectd.conf, debian/filters.conf: - Added a sample filter chain configuration. * debian/rules: @@ -19,7 +22,7 @@ collectd (4.6.2-2) unstable; urgency=low libiptc which is available as shared library since iptables 1.4.3. Depend on versions >= 1.4.3.2-2 because of #524766. - -- Sebastian Harl Tue, 05 May 2009 22:59:33 +0200 + -- Sebastian Harl Thu, 28 May 2009 16:23:01 +0200 collectd (4.6.2-1) unstable; urgency=low diff --git a/debian/patches/00list b/debian/patches/00list index 63040b3..1a38c72 100644 --- a/debian/patches/00list +++ b/debian/patches/00list @@ -2,4 +2,5 @@ rrd_filter_path.dpatch collection_conf_path.dpatch battery_acpi_complain.dpatch ntpd_type_pun_fix.dpatch +include_empty_files.dpatch diff --git a/debian/patches/include_empty_files.dpatch b/debian/patches/include_empty_files.dpatch new file mode 100755 index 0000000..cf6d673 --- /dev/null +++ b/debian/patches/include_empty_files.dpatch @@ -0,0 +1,54 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## include_empty_files.dpatch by Sebastian Harl +## +## DP: configfile.c: Fixed Include'ing empty files. +## DP: +## DP: When including empty files, a typo prevented that the "Include" child +## DP: (of the config parse tree) was removed correctly, leaving behind +## DP: garbage which in turn led to a segfault if the Include option was not +## DP: the last element of the config file. +## DP: +## DP: Also, another Include option following the inclusion of an empty file +## DP: used to be ignored. This has been fixed as well. + +@DPATCH@ + +diff a/src/configfile.c b/src/configfile.c +--- a/src/configfile.c ++++ b/src/configfile.c +@@ -378,12 +378,12 @@ static int cf_ci_replace_child (oconfig_item_t *dst, oconfig_item_t *src, + temp = NULL; + + /* If (src->children_num == 0) the array size is decreased. If offset +- * is _not_ the last element, (offset < (src->children_num - 1)), then ++ * is _not_ the last element, (offset < (dst->children_num - 1)), then + * we need to move the trailing elements before resizing the array. */ +- if ((src->children_num == 0) && (offset < (src->children_num - 1))) ++ if ((src->children_num == 0) && (offset < (dst->children_num - 1))) + { +- int nmemb = src->children_num - (offset + 1); +- memmove (src->children + offset, src->children + offset + 1, ++ int nmemb = dst->children_num - (offset + 1); ++ memmove (dst->children + offset, dst->children + offset + 1, + sizeof (oconfig_item_t) * nmemb); + } + +@@ -415,7 +415,7 @@ static int cf_ci_replace_child (oconfig_item_t *dst, oconfig_item_t *src, + sizeof (oconfig_item_t) * nmemb); + } + +- /* Last but not least: If there are new childrem, copy them to the ++ /* Last but not least: If there are new children, copy them to the + * memory reserved for them. */ + if (src->children_num > 0) + { +@@ -491,6 +491,9 @@ static int cf_include_all (oconfig_item_t *root, int depth) + /* Now replace the i'th child in `root' with `new'. */ + cf_ci_replace_child (root, new, i); + ++ /* ... and go back to the new i'th child. */ ++ --i; ++ + sfree (new->values); + sfree (new); + } /* for (i = 0; i < root->children_num; i++) */ -- 2.30.2