cf_read_generic() returned NULL in two cases: Unable to read file and
file was empty. Since we wanted to allow empty includes, the "include
file with errors" case was not handled properly.
Github: #323
new = cf_read_generic (old->values[0].value.string, depth + 1);
if (new == NULL)
new = cf_read_generic (old->values[0].value.string, depth + 1);
if (new == NULL)
/* Now replace the i'th child in `root' with `new'. */
cf_ci_replace_child (root, new, i);
/* Now replace the i'th child in `root' with `new'. */
cf_ci_replace_child (root, new, i);
static oconfig_item_t *cf_read_file (const char *file, int depth)
{
oconfig_item_t *root;
static oconfig_item_t *cf_read_file (const char *file, int depth)
{
oconfig_item_t *root;
assert (depth < CF_MAX_DEPTH);
assert (depth < CF_MAX_DEPTH);
- 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 */
- 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 */
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++)
{