Blame SOURCES/dovecot-2.3.10-CVE_2020_10957p2.patch

311a5d
From aedb205c79395de77127fb7166b29b09319df23c Mon Sep 17 00:00:00 2001
311a5d
From: Stephan Bosch <stephan.bosch@open-xchange.com>
311a5d
Date: Tue, 24 Mar 2020 21:11:01 +0100
311a5d
Subject: [PATCH] lib-smtp: smtp-syntax - Do not allow NULL return parameters
311a5d
 for smtp_xtext_parse().
311a5d
311a5d
---
311a5d
 src/lib-smtp/smtp-syntax.c | 15 +++++++--------
311a5d
 1 file changed, 7 insertions(+), 8 deletions(-)
311a5d
311a5d
diff --git a/src/lib-smtp/smtp-syntax.c b/src/lib-smtp/smtp-syntax.c
311a5d
index 6826682af1..0b0a91ce07 100644
311a5d
--- a/src/lib-smtp/smtp-syntax.c
311a5d
+++ b/src/lib-smtp/smtp-syntax.c
311a5d
@@ -86,20 +86,20 @@ int smtp_xtext_parse(const char *xtext,
311a5d
 {
311a5d
 	struct smtp_parser parser;
311a5d
 	string_t *value = NULL;
311a5d
-	int ret;
311a5d
+
311a5d
+	*value_r = NULL;
311a5d
+	*error_r = NULL;
311a5d
 
311a5d
 	if (xtext == NULL || *xtext == '\0') {
311a5d
 		*value_r = "";
311a5d
 		return 1;
311a5d
 	}
311a5d
 
311a5d
-	if (value_r != NULL)
311a5d
-		value = t_str_new(256);
311a5d
+	value = t_str_new(256);
311a5d
 	smtp_parser_init(&parser, pool_datastack_create(), xtext);
311a5d
 
311a5d
-	if ((ret=smtp_parser_parse_xtext(&parser, value)) < 0) {
311a5d
-		if (error_r != NULL)
311a5d
-			*error_r = parser.error;
311a5d
+	if (smtp_parser_parse_xtext(&parser, value) < 0) {
311a5d
+		*error_r = parser.error;
311a5d
 		return -1;
311a5d
 	}
311a5d
 	if (parser.cur < parser.end) {
311a5d
@@ -110,8 +110,7 @@ int smtp_xtext_parse(const char *xtext,
311a5d
 	if (value_r != NULL) {
311a5d
 		*value_r = str_c(value);
311a5d
 		if (strlen(*value_r) != str_len(value)) {
311a5d
-			if (*error_r != NULL)
311a5d
-				*error_r = "Encountered NUL character in xtext";
311a5d
+			*error_r = "Encountered NUL character in xtext";
311a5d
 			return -1;
311a5d
 		}
311a5d
 	}