otherwise, when run on empty file, the main section defaults
are not filled in and program may crash.
const struct CfContext *cf;
const char *cur_sect;
void *top_base;
+ bool got_main_sect;
};
static bool fill_defaults(struct LoaderCtx *ctx)
if (!s)
goto fail;
+ if (s == ctx->cf->sect_list)
+ ctx->got_main_sect = true;
+
if (s->section_start) {
if (!s->section_start(ctx->top_base, ctx->cur_sect))
return false;
ok = parse_ini_file(fn, load_handler, &ctx);
if (ctx.cur_sect)
free(ctx.cur_sect);
+ if (ok && !ctx.got_main_sect) {
+ log_error("load_init_file: main section missing from config file");
+ return false;
+ }
return ok;
}