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-5.5'
[collectd.git]
/
src
/
daemon
/
configfile.c
diff --git
a/src/daemon/configfile.c
b/src/daemon/configfile.c
index
f34adae
..
89b0be0
100644
(file)
--- a/
src/daemon/configfile.c
+++ b/
src/daemon/configfile.c
@@
-156,9
+156,12
@@
static int cf_dispatch (const char *type, const char *orig_key,
int ret;
int i;
int ret;
int i;
+ if (orig_key == NULL)
+ return (EINVAL);
+
DEBUG ("type = %s, key = %s, value = %s",
ESCAPE_NULL(type),
DEBUG ("type = %s, key = %s, value = %s",
ESCAPE_NULL(type),
-
ESCAPE_NULL(orig_key)
,
+
orig_key
,
ESCAPE_NULL(orig_value));
if ((cf_cb = cf_search (type)) == NULL)
ESCAPE_NULL(orig_value));
if ((cf_cb = cf_search (type)) == NULL)
@@
-199,8
+202,6
@@
static int cf_dispatch (const char *type, const char *orig_key,
free (key);
free (value);
free (key);
free (value);
- DEBUG ("cf_dispatch: return (%i)", ret);
-
return (ret);
} /* int cf_dispatch */
return (ret);
} /* int cf_dispatch */
@@
-627,8
+628,11
@@
static int cf_include_all (oconfig_item_t *root, int depth)
return (-1);
/* Now replace the i'th child in `root' with `new'. */
return (-1);
/* Now replace the i'th child in `root' with `new'. */
- if (cf_ci_replace_child (root, new, i) < 0)
+ if (cf_ci_replace_child (root, new, i) < 0) {
+ sfree (new->values);
+ sfree (new);
return (-1);
return (-1);
+ }
/* ... and go back to the new i'th child. */
--i;
/* ... and go back to the new i'th child. */
--i;
@@
-717,6
+721,7
@@
static oconfig_item_t *cf_read_dir (const char *dir,
if (root == NULL)
{
ERROR ("configfile: malloc failed.");
if (root == NULL)
{
ERROR ("configfile: malloc failed.");
+ closedir (dh);
return (NULL);
}
memset (root, 0, sizeof (oconfig_item_t));
return (NULL);
}
memset (root, 0, sizeof (oconfig_item_t));
@@
-736,6
+741,7
@@
static oconfig_item_t *cf_read_dir (const char *dir,
ERROR ("configfile: Not including `%s/%s' because its"
" name is too long.",
dir, de->d_name);
ERROR ("configfile: Not including `%s/%s' because its"
" name is too long.",
dir, de->d_name);
+ closedir (dh);
for (i = 0; i < filenames_num; ++i)
free (filenames[i]);
free (filenames);
for (i = 0; i < filenames_num; ++i)
free (filenames[i]);
free (filenames);
@@
-748,6
+754,7
@@
static oconfig_item_t *cf_read_dir (const char *dir,
filenames_num * sizeof (*filenames));
if (tmp == NULL) {
ERROR ("configfile: realloc failed.");
filenames_num * sizeof (*filenames));
if (tmp == NULL) {
ERROR ("configfile: realloc failed.");
+ closedir (dh);
for (i = 0; i < filenames_num - 1; ++i)
free (filenames[i]);
free (filenames);
for (i = 0; i < filenames_num - 1; ++i)
free (filenames[i]);
free (filenames);
@@
-759,6
+766,12
@@
static oconfig_item_t *cf_read_dir (const char *dir,
filenames[filenames_num - 1] = sstrdup (name);
}
filenames[filenames_num - 1] = sstrdup (name);
}
+ if (filenames == NULL)
+ {
+ closedir (dh);
+ return (root);
+ }
+
qsort ((void *) filenames, filenames_num, sizeof (*filenames),
cf_compare_string);
qsort ((void *) filenames, filenames_num, sizeof (*filenames),
cf_compare_string);
@@
-782,11
+795,12
@@
static oconfig_item_t *cf_read_dir (const char *dir,
free (name);
}
free (name);
}
+ closedir (dh);
free(filenames);
return (root);
} /* oconfig_item_t *cf_read_dir */
free(filenames);
return (root);
} /* oconfig_item_t *cf_read_dir */
-/*
+/*
* cf_read_generic
*
* Path is stat'ed and either cf_read_file or cf_read_dir is called
* cf_read_generic
*
* Path is stat'ed and either cf_read_file or cf_read_dir is called