From: Florian Forster Date: Wed, 24 Jul 2013 12:12:53 +0000 (+0200) Subject: rrdcached, rrdtool plugins: Honor the "DataDir" setting. X-Git-Tag: collectd-5.4.0~1^2^2~5 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6ef3385ccec835c7efae1ff3d5895858003a6da7;p=collectd.git rrdcached, rrdtool plugins: Honor the "DataDir" setting. This fixes a regression introduced in: bfd3f06ef4996707036756371c5724ebf2748821 Github: #380 --- diff --git a/src/rrdcached.c b/src/rrdcached.c index cf238031..a8305e63 100644 --- a/src/rrdcached.c +++ b/src/rrdcached.c @@ -119,6 +119,18 @@ static int value_list_to_filename (char *buffer, size_t buffer_size, int status; size_t len; + if (datadir != NULL) + { + size_t datadir_len = strlen (datadir); + + if (datadir_len >= buffer_size) + return (ENOMEM); + + sstrncpy (buffer, datadir, buffer_size); + buffer += datadir_len; + buffer_size -= datadir_len; + } + status = FORMAT_VL (buffer, buffer_size, vl); if (status != 0) return (status); diff --git a/src/rrdtool.c b/src/rrdtool.c index 916ce01d..a4688674 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -1,6 +1,6 @@ /** * collectd - src/rrdtool.c - * Copyright (C) 2006-2008 Florian octo Forster + * Copyright (C) 2006-2013 Florian octo Forster * Copyright (C) 2008-2008 Sebastian Harl * Copyright (C) 2009 Mariusz Gronczewski * @@ -18,7 +18,7 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * Authors: - * Florian octo Forster + * Florian octo Forster * Sebastian Harl * Mariusz Gronczewski **/ @@ -247,6 +247,18 @@ static int value_list_to_filename (char *buffer, size_t buffer_size, int status; size_t len; + if (datadir != NULL) + { + size_t datadir_len = strlen (datadir); + + if (datadir_len >= buffer_size) + return (ENOMEM); + + sstrncpy (buffer, datadir, buffer_size); + buffer += datadir_len; + buffer_size -= datadir_len; + } + status = FORMAT_VL (buffer, buffer_size, vl); if (status != 0) return (status);