Skip to content
Snippets Groups Projects
Commit 45717535 authored by Jan Včelák's avatar Jan Včelák :rocket:
Browse files

config parser: do not output garbage when braces are unbalanced

refs #172
parent 165e6ca9
No related branches found
No related tags found
No related merge requests found
......@@ -303,8 +303,10 @@ hmac-sha512 { lval.alg = KNOT_TSIG_ALG_HMAC_SHA512; return TSIG_ALGO_NAME; }
char *name = conf_includes_pop(yyextra->includes);
free(name);
yypop_buffer_state(yyscanner);
if (!YY_CURRENT_BUFFER)
if (!YY_CURRENT_BUFFER) {
return END;
}
}
<include>{BLANK}+
......
......@@ -73,14 +73,17 @@ static void cf_print_error(void *scanner, const char *msg)
if (scanner) {
extra = cf_get_extra(scanner);
lineno = cf_get_lineno(scanner);
text = cf_get_text(scanner);
filename = conf_includes_top(extra->includes);
extra->error = true;
}
if (!filename)
if (extra && lineno != 0) {
text = cf_get_text(scanner);
}
if (!filename) {
filename = new_config->filename;
}
log_server_error("Config error in '%s' (line %d token '%s') - %s\n",
filename, lineno, text, msg);
......
......@@ -29,8 +29,9 @@
conf_extra_t *conf_extra_init(const char *file, int includes_max_depth)
{
conf_extra_t *extra = calloc(1, sizeof(conf_extra_t));
if (!extra)
if (!extra) {
return NULL;
}
conf_includes_t *includes = conf_includes_init(includes_max_depth);
if (!includes) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment