From c6597ef738a9b8633e09546c93859402f7598e1e Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 20 Apr 2007 08:33:07 +0200 Subject: [PATCH] rrdtool plugin: config: Copy `value' before modifying it. --- src/rrdtool.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/rrdtool.c b/src/rrdtool.c index 814b3e39..b4bb3fbe 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -772,9 +772,14 @@ static int rrd_config (const char *key, const char *value) char *saveptr = NULL; char *dummy; char *ptr; + char *value_copy; int *tmp_alloc; - dummy = value; + value_copy = strdup (value); + if (value_copy == NULL) + return (1); + + dummy = value_copy; while ((ptr = strtok_r (dummy, ", \t", &saveptr)) != NULL) { dummy = NULL; @@ -784,6 +789,7 @@ static int rrd_config (const char *key, const char *value) if (tmp_alloc == NULL) { fprintf (stderr, "rrdtool: realloc failed.\n"); + free (value_copy); return (1); } rra_timespans_custom = tmp_alloc; @@ -791,7 +797,7 @@ static int rrd_config (const char *key, const char *value) if (rra_timespans_custom[rra_timespans_custom_num] != 0) rra_timespans_custom_num++; } /* while (strtok_r) */ - + free (value_copy); } else if (strcasecmp ("XFF", key) == 0) { -- 2.30.2