From 0f37a46f30449c457fc1b55254d049b4d7fac837 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Kundr=C3=A1t?= Date: Wed, 26 Feb 2014 02:57:19 +0100 Subject: [PATCH] Fix rrdc_fetch behavior on RRDs with multiple DSes When reading values from RRD files with multiple data sets, the auxiliary parsing function would only copy the first item from the returned list; the others were left uninitialized. On my x64_64 Linux machine, this actually reused values form previous call to parse_char_array_header which happens to be a DS definition. Given a RRD file with DS "a", "b" and "c", the first value on each line would be correctly parsed, but the second value is "b", the actual DS name, and the third one "c". These "values" cannot be parsed as numbers, and the whole function therefore returns with an error. Making sure that all pointers within the array are copied therefore fixes this problem. --- src/rrd_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rrd_client.c b/src/rrd_client.c index d796a2bd..783daf12 100644 --- a/src/rrd_client.c +++ b/src/rrd_client.c @@ -207,7 +207,7 @@ static int parse_char_array_header (char *line, /* {{{ */ if (alloc == 0) { - memcpy (array, tmp_array, sizeof (tmp_array)); + memcpy (array, tmp_array, array_len * sizeof (char*)); } else { -- 2.47.2