projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #1454 from rubenk/libi2c-dev-mark-as-linux-only
[collectd.git]
/
src
/
rrdtool.c
diff --git
a/src/rrdtool.c
b/src/rrdtool.c
index
26d1638
..
4a3c345
100644
(file)
--- a/
src/rrdtool.c
+++ b/
src/rrdtool.c
@@
-1008,23
+1008,32
@@
static int rrd_config (const char *key, const char *value)
}
else if (strcasecmp ("DataDir", key) == 0)
{
}
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)
{
}
else if (strcasecmp ("StepSize", key) == 0)
{