dovecot-2.0: settings_parse_stream*() could have stopped after r...

dovecot at dovecot.org dovecot at dovecot.org
Sat May 23 01:28:13 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/9f2403f3e345
changeset: 9352:9f2403f3e345
user:      Timo Sirainen <tss at iki.fi>
date:      Fri May 22 18:28:08 2009 -0400
description:
settings_parse_stream*() could have stopped after reading unknown settings.

diffstat:

1 file changed, 10 insertions(+), 13 deletions(-)
src/lib-settings/settings-parser.c |   23 ++++++++++-------------

diffs (47 lines):

diff -r 8524ed76b929 -r 9f2403f3e345 src/lib-settings/settings-parser.c
--- a/src/lib-settings/settings-parser.c	Fri May 22 18:26:07 2009 -0400
+++ b/src/lib-settings/settings-parser.c	Fri May 22 18:28:08 2009 -0400
@@ -466,14 +466,15 @@ int settings_parse_stream(struct setting
 int settings_parse_stream(struct setting_parser_context *ctx,
 			  struct istream *input)
 {
+	bool ignore_unknown_keys =
+		(ctx->flags & SETTINGS_PARSER_FLAG_IGNORE_UNKNOWN_KEYS) != 0;
 	const char *line;
-	int ret = 1;
+	int ret;
 
 	while ((line = i_stream_next_line(input)) != NULL) {
 		if (*line == '\0') {
 			/* empty line finishes it */
-			ret = 0;
-			break;
+			return 0;
 		}
 		ctx->linenum++;
 
@@ -481,18 +482,14 @@ int settings_parse_stream(struct setting
 			line = settings_translate_lf(line);
 			ret = settings_parse_line(ctx, line);
 		} T_END;
-		if (ret == 0 && (ctx->flags &
-				 SETTINGS_PARSER_FLAG_IGNORE_UNKNOWN_KEYS) == 0)
-			ret = -1;
-
-		if (ret < 0) {
+
+		if (ret < 0 || (ret == 0 && !ignore_unknown_keys)) {
 			ctx->error = p_strdup_printf(ctx->parser_pool,
 				"Line %u: %s", ctx->linenum, ctx->error);
-			ret = -1;
-			break;
-		}
-	}
-	return ret;
+			return -1;
+		}
+	}
+	return 1;
 }
 
 int settings_parse_stream_read(struct setting_parser_context *ctx,


More information about the dovecot-cvs mailing list