From f691580f7450b41bb3de36d825fc46fa5071cabf Mon Sep 17 00:00:00 2001
Date: Mon, 26 Oct 2020 18:52:57 +0800
Subject: [PATCH] fix CVE-2020-12100

---
 .../src/lib-sieve/plugins/notify/ext-notify-common.c |  3 ++-
 .../src/lib-sieve/sieve-message.c                    | 12 ++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/dovecot-2.3-pigeonhole-0.5.10/src/lib-sieve/plugins/notify/ext-notify-common.c b/dovecot-2.3-pigeonhole-0.5.10/src/lib-sieve/plugins/notify/ext-notify-common.c
index 700b79d..9d950f3 100644
--- a/dovecot-2.3-pigeonhole-0.5.10/src/lib-sieve/plugins/notify/ext-notify-common.c
+++ b/dovecot-2.3-pigeonhole-0.5.10/src/lib-sieve/plugins/notify/ext-notify-common.c
@@ -156,6 +156,7 @@ cmd_notify_extract_body_text(const struct sieve_runtime_env *renv,
 {
 	const struct sieve_execute_env *eenv = renv->exec_env;
 	const struct sieve_extension *this_ext = renv->oprtn->ext;
+	const struct message_parser_settings parser_set = { .flags = 0 };
 	struct ext_notify_message_context *mctx;
 	struct mail *mail = eenv->msgdata->mail;
 	struct message_parser_ctx *parser;
@@ -189,7 +190,7 @@ cmd_notify_extract_body_text(const struct sieve_runtime_env *renv,
 	/* Initialize body decoder */
 	decoder = message_decoder_init(NULL, 0);
 
-	parser = message_parser_init(mctx->pool, input, 0, 0);
+	parser = message_parser_init(mctx->pool, input, &parser_set);
 	is_text = TRUE;
 	save_body = FALSE;
 	while ((ret = message_parser_parse_next_block(parser, &block)) > 0) {
diff --git a/dovecot-2.3-pigeonhole-0.5.10/src/lib-sieve/sieve-message.c b/dovecot-2.3-pigeonhole-0.5.10/src/lib-sieve/sieve-message.c
index afbf31f..c791758 100644
--- a/dovecot-2.3-pigeonhole-0.5.10/src/lib-sieve/sieve-message.c
+++ b/dovecot-2.3-pigeonhole-0.5.10/src/lib-sieve/sieve-message.c
@@ -1081,10 +1081,10 @@ static int sieve_message_parts_add_missing
 	struct sieve_message_context *msgctx = renv->msgctx;
 	pool_t pool = msgctx->context_pool;
 	struct mail *mail = sieve_message_get_mail(renv->msgctx);
-	enum message_parser_flags mparser_flags =
-		MESSAGE_PARSER_FLAG_INCLUDE_MULTIPART_BLOCKS;
-	enum message_header_parser_flags hparser_flags =
-		MESSAGE_HEADER_PARSER_FLAG_SKIP_INITIAL_LWSP;
+	struct message_parser_settings parser_set = {
+		.hdr_flags = MESSAGE_HEADER_PARSER_FLAG_SKIP_INITIAL_LWSP,
+		.flags = MESSAGE_PARSER_FLAG_INCLUDE_MULTIPART_BLOCKS,
+	};
 	ARRAY(struct sieve_message_header) headers;
 	struct sieve_message_part *body_part, *header_part, *last_part;
 	struct message_parser_ctx *parser;
@@ -1121,7 +1121,7 @@ static int sieve_message_parts_add_missing
 	if (iter_all) {
 		t_array_init(&headers, 64);
 		hdr_content = t_str_new(512);
-		hparser_flags |= MESSAGE_HEADER_PARSER_FLAG_CLEAN_ONELINE;
+		parser_set.hdr_flags |= MESSAGE_HEADER_PARSER_FLAG_CLEAN_ONELINE;
 	} else {
 		i_zero(&headers);
 	}
@@ -1133,7 +1133,7 @@ static int sieve_message_parts_add_missing
 		//parser = message_parser_init_from_parts(parts, input,
 		// hparser_flags, mparser_flags);
 	parser = message_parser_init(pool_datastack_create(),
-		input, hparser_flags, mparser_flags);
+		input, &parser_set);
 	while ( (ret=message_parser_parse_next_block
 		(parser, &block)) > 0 ) {
 		struct sieve_message_part **body_part_idx;
-- 
2.23.0

