Blame SOURCES/dovecot-2.2.36-cve2019_11500_part1of4.patch

158b54
From 58ffd3e8a02e54fc98b6be78e02b0511ee9263eb Mon Sep 17 00:00:00 2001
158b54
From: Timo Sirainen <timo.sirainen@open-xchange.com>
158b54
Date: Fri, 10 May 2019 19:24:51 +0300
158b54
Subject: [PATCH 1/2] lib-imap: Don't accept strings with NULs
158b54
158b54
IMAP doesn't allow NULs except in binary literals. We'll still allow them
158b54
in regular literals as well, but just not in strings.
158b54
158b54
This fixes a bug with unescaping a string with NULs: str_unescape() could
158b54
have been called for memory that points outside the allocated string,
158b54
causing heap corruption. This could cause crashes or theoretically even
158b54
result in remote code execution exploit.
158b54
158b54
Found by Nick Roessler and Rafi Rubin
158b54
---
158b54
 src/lib-imap/imap-parser.c | 6 ++++++
158b54
 1 file changed, 6 insertions(+)
158b54
158b54
diff --git a/src/lib-imap/imap-parser.c b/src/lib-imap/imap-parser.c
158b54
index dddf55189..f41668d7a 100644
158b54
--- a/src/lib-imap/imap-parser.c
158b54
+++ b/src/lib-imap/imap-parser.c
158b54
@@ -363,6 +363,11 @@ static bool imap_parser_read_string(struct imap_parser *parser,
158b54
 			break;
158b54
 		}
158b54
 
158b54
+		if (data[i] == '\0') {
158b54
+			parser->error = "NULs not allowed in strings";
158b54
+			return FALSE;
158b54
+		}
158b54
+
158b54
 		if (data[i] == '\\') {
158b54
 			if (i+1 == data_size) {
158b54
 				/* known data ends with '\' - leave it to
158b54
-- 
158b54
2.11.0
158b54