[collectd] [PATCH] filecount plugin: Fixed an off-by-one error in the configuration code.

Sebastian Harl sh at tokkee.org
Thu Oct 30 16:43:01 CET 2008


The memory allocated to store the information about configured directories did
not take into account the newly added directory. This would cause a segfault
at some point of time (when specifying more than four directories in my case).

Thanks to Martin Janota <janota.m at cce.cz> for finding and reporting this bug.
---

This patch is also available in the sh/collectd-4.5 branch at
git://git.tokkee.org/collectd.git.

---
 src/filecount.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/filecount.c b/src/filecount.c
index 55b3655..f071379 100644
--- a/src/filecount.c
+++ b/src/filecount.c
@@ -371,7 +371,7 @@ static int fc_config_add_dir (oconfig_item_t *ci)
     fc_directory_conf_t **temp;
 
     temp = (fc_directory_conf_t **) realloc (directories,
-        sizeof (*directories) * directories_num);
+        sizeof (*directories) * (directories_num + 1));
     if (temp == NULL)
     {
       ERROR ("filecount plugin: realloc failed.");
-- 
1.6.0.3.523.g304d0

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20081030/ea3599aa/attachment.pgp 


More information about the collectd mailing list