summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 07f6de7)
raw | patch | inline | side by side (parent: 07f6de7)
author | Florian Forster <octo@collectd.org> | |
Tue, 8 Dec 2015 13:22:54 +0000 (14:22 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Tue, 8 Dec 2015 13:22:54 +0000 (14:22 +0100) |
CID: 37977
src/rrdtool.c | patch | blob | history |
diff --git a/src/rrdtool.c b/src/rrdtool.c
index 9b5723ad2992c4d3cdcaa448c9462afead768866..9b04d10ef753a8cf4818587dda4be1ebc340ad59 100644 (file)
--- a/src/rrdtool.c
+++ b/src/rrdtool.c
}
else if (strcasecmp ("DataDir", key) == 0)
{
- if (datadir != NULL)
- free (datadir);
- datadir = strdup (value);
- if (datadir != NULL)
+ char *tmp;
+ size_t len;
+
+ tmp = strdup (value);
+ if (tmp == NULL)
{
- int len = strlen (datadir);
- while ((len > 0) && (datadir[len - 1] == '/'))
- {
- len--;
- datadir[len] = '\0';
- }
- if (len <= 0)
- {
- free (datadir);
- datadir = NULL;
- }
+ ERROR ("rrdtool plugin: strdup failed.");
+ return (1);
+ }
+
+ len = strlen (datadir);
+ while ((len > 0) && (datadir[len - 1] == '/'))
+ {
+ len--;
+ datadir[len] = 0;
}
+
+ if (len == 0)
+ {
+ ERROR ("rrdtool plugin: Invalid \"DataDir\" option.");
+ sfree (tmp);
+ return (1);
+ }
+
+ sfree (datadir);
+ datadir = tmp;
}
else if (strcasecmp ("StepSize", key) == 0)
{