From 1618629fd55e914c8d2e28fc01b8264613f00a99 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 4 Nov 2010 15:47:37 +0000 Subject: [PATCH] config parser: Log an error about missing '}'. --- src/config/config-parser-private.h | 3 +++ src/config/config-parser.c | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/config/config-parser-private.h b/src/config/config-parser-private.h index 49849e4c6b..fca68e1f6a 100644 --- a/src/config/config-parser-private.h +++ b/src/config/config-parser-private.h @@ -23,6 +23,9 @@ struct config_section_stack { /* root=NULL-terminated list of parsers */ struct config_module_parser *parsers; unsigned int pathlen; + + const char *open_path; + unsigned int open_linenum; }; struct input_stack { diff --git a/src/config/config-parser.c b/src/config/config-parser.c index bd007adeb4..706e1e398a 100644 --- a/src/config/config-parser.c +++ b/src/config/config-parser.c @@ -165,6 +165,9 @@ config_add_new_section(struct config_parser_context *ctx) section->prev = ctx->cur_section; section->filter = ctx->cur_section->filter; section->parsers = ctx->cur_section->parsers; + + section->open_path = p_strdup(ctx->pool, ctx->cur_input->path); + section->open_linenum = ctx->cur_input->linenum; return section; } @@ -312,6 +315,14 @@ config_all_parsers_check(struct config_parser_context *ctx, pool_t tmp_pool; int ret = 0; + if (ctx->cur_section->prev != NULL) { + *error_r = t_strdup_printf( + "Missing '}' (section started at %s:%u)", + ctx->cur_section->open_path, + ctx->cur_section->open_linenum); + return -1; + } + tmp_pool = pool_alloconly_create("config parsers check", 1024*32); parsers = array_get(&ctx->all_parsers, &count); i_assert(count > 0 && parsers[count-1] == NULL); -- 2.47.3