X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fconfigfile.c;h=d6c224fd74966e23f6758ee79be11b75a67e5960;hb=38d06a8f868293466f4eee943555c65457a5e560;hp=876ee23ee71c8c33d2f230170bf94147a6012404;hpb=a02ced789b4c93f293dc9d14a5a303c5fe11bcce;p=collectd.git diff --git a/src/configfile.c b/src/configfile.c index 876ee23e..d6c224fd 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -586,7 +586,7 @@ static int cf_include_all (oconfig_item_t *root, int depth) sfree (pattern); if (new == NULL) - continue; + return (-1); /* Now replace the i'th child in `root' with `new'. */ cf_ci_replace_child (root, new, i); @@ -605,6 +605,7 @@ static oconfig_item_t *cf_read_file (const char *file, const char *pattern, int depth) { oconfig_item_t *root; + int status; assert (depth < CF_MAX_DEPTH); @@ -636,7 +637,12 @@ static oconfig_item_t *cf_read_file (const char *file, 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 */ @@ -829,12 +835,6 @@ static oconfig_item_t *cf_read_generic (const char *path, wordfree (&we); - if (root->children == NULL) - { - oconfig_free (root); - return (NULL); - } - return (root); } /* oconfig_item_t *cf_read_generic */ /* #endif HAVE_WORDEXP_H */ @@ -1046,6 +1046,12 @@ int cf_read (char *filename) 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++) {