dovecot-2.0: config parser: Log an error about missing '}'.

dovecot at dovecot.org dovecot at dovecot.org
Thu Nov 4 17:47:41 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/e57054f88e66
changeset: 12383:e57054f88e66
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Nov 04 15:47:37 2010 +0000
description:
config parser: Log an error about missing '}'.

diffstat:

 src/config/config-parser-private.h |   3 +++
 src/config/config-parser.c         |  11 +++++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diffs (41 lines):

diff -r af252c044393 -r e57054f88e66 src/config/config-parser-private.h
--- a/src/config/config-parser-private.h	Thu Nov 04 14:11:15 2010 +0000
+++ b/src/config/config-parser-private.h	Thu Nov 04 15:47:37 2010 +0000
@@ -23,6 +23,9 @@
 	/* 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 -r af252c044393 -r e57054f88e66 src/config/config-parser.c
--- a/src/config/config-parser.c	Thu Nov 04 14:11:15 2010 +0000
+++ b/src/config/config-parser.c	Thu Nov 04 15:47:37 2010 +0000
@@ -165,6 +165,9 @@
 	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 @@
 	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);


More information about the dovecot-cvs mailing list