projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'collectd-4.10' into collectd-5.3
[collectd.git]
/
src
/
configfile.c
diff --git
a/src/configfile.c
b/src/configfile.c
index
d6aa72d
..
7e06baa
100644
(file)
--- a/
src/configfile.c
+++ b/
src/configfile.c
@@
-98,7
+98,7
@@
static cf_value_map_t cf_value_map[] =
{"PluginDir", dispatch_value_plugindir},
{"LoadPlugin", dispatch_loadplugin}
};
{"PluginDir", dispatch_value_plugindir},
{"LoadPlugin", dispatch_loadplugin}
};
-static int cf_value_map_num = STATIC_ARRAY_
LEN
(cf_value_map);
+static int cf_value_map_num = STATIC_ARRAY_
SIZE
(cf_value_map);
static cf_global_option_t cf_global_options[] =
{
static cf_global_option_t cf_global_options[] =
{
@@
-108,11
+108,12
@@
static cf_global_option_t cf_global_options[] =
{"FQDNLookup", NULL, "true"},
{"Interval", NULL, NULL},
{"ReadThreads", NULL, "5"},
{"FQDNLookup", NULL, "true"},
{"Interval", NULL, NULL},
{"ReadThreads", NULL, "5"},
+ {"WriteThreads", NULL, "5"},
{"Timeout", NULL, "2"},
{"PreCacheChain", NULL, "PreCache"},
{"PostCacheChain", NULL, "PostCache"}
};
{"Timeout", NULL, "2"},
{"PreCacheChain", NULL, "PreCache"},
{"PostCacheChain", NULL, "PostCache"}
};
-static int cf_global_options_num = STATIC_ARRAY_
LEN
(cf_global_options);
+static int cf_global_options_num = STATIC_ARRAY_
SIZE
(cf_global_options);
static int cf_default_typesdb = 1;
static int cf_default_typesdb = 1;
@@
-475,6
+476,12
@@
static int cf_ci_replace_child (oconfig_item_t *dst, oconfig_item_t *src,
/* Resize the memory containing the children to be big enough to hold
* all children. */
/* Resize the memory containing the children to be big enough to hold
* all children. */
+ if (dst->children_num + src->children_num - 1 == 0)
+ {
+ dst->children_num = 0;
+ return (0);
+ }
+
temp = (oconfig_item_t *) realloc (dst->children,
sizeof (oconfig_item_t)
* (dst->children_num + src->children_num - 1));
temp = (oconfig_item_t *) realloc (dst->children,
sizeof (oconfig_item_t)
* (dst->children_num + src->children_num - 1));
@@
-583,11
+590,14
@@
static int cf_include_all (oconfig_item_t *root, int depth)
}
new = cf_read_generic (old->values[0].value.string, pattern, depth + 1);
}
new = cf_read_generic (old->values[0].value.string, pattern, depth + 1);
+ sfree (pattern);
+
if (new == NULL)
if (new == NULL)
-
continue
;
+
return (-1)
;
/* Now replace the i'th child in `root' with `new'. */
/* Now replace the i'th child in `root' with `new'. */
- cf_ci_replace_child (root, new, i);
+ if (cf_ci_replace_child (root, new, i) < 0)
+ return (-1);
/* ... and go back to the new i'th child. */
--i;
/* ... and go back to the new i'th child. */
--i;
@@
-603,6
+613,7
@@
static oconfig_item_t *cf_read_file (const char *file,
const char *pattern, int depth)
{
oconfig_item_t *root;
const char *pattern, int depth)
{
oconfig_item_t *root;
+ int status;
assert (depth < CF_MAX_DEPTH);
assert (depth < CF_MAX_DEPTH);
@@
-634,7
+645,12
@@
static oconfig_item_t *cf_read_file (const char *file,
return (NULL);
}
return (NULL);
}
- cf_include_all (root, depth);
+ status = cf_include_all (root, depth);
+ if (status != 0)
+ {
+ oconfig_free (root);
+ return (NULL);
+ }
return (root);
} /* oconfig_item_t *cf_read_file */
return (root);
} /* oconfig_item_t *cf_read_file */
@@
-827,12
+843,6
@@
static oconfig_item_t *cf_read_generic (const char *path,
wordfree (&we);
wordfree (&we);
- if (root->children == NULL)
- {
- oconfig_free (root);
- return (NULL);
- }
-
return (root);
} /* oconfig_item_t *cf_read_generic */
/* #endif HAVE_WORDEXP_H */
return (root);
} /* oconfig_item_t *cf_read_generic */
/* #endif HAVE_WORDEXP_H */
@@
-1044,6
+1054,12
@@
int cf_read (char *filename)
ERROR ("Unable to read config file %s.", filename);
return (-1);
}
ERROR ("Unable to read config file %s.", filename);
return (-1);
}
+ else if (conf->children_num == 0)
+ {
+ ERROR ("Configuration file %s is empty.", filename);
+ oconfig_free (conf);
+ return (-1);
+ }
for (i = 0; i < conf->children_num; i++)
{
for (i = 0; i < conf->children_num; i++)
{