File 0003-lib-smtp-smtp-syntax-Do-not-allow-NULL-return-parame.patch of Package dovecot23.15100

From aedb205c79395de77127fb7166b29b09319df23c Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan.bosch@open-xchange.com>
Date: Tue, 24 Mar 2020 21:11:01 +0100
Subject: [PATCH 03/16] lib-smtp: smtp-syntax - Do not allow NULL return
 parameters for smtp_xtext_parse().

---
 src/lib-smtp/smtp-syntax.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/lib-smtp/smtp-syntax.c b/src/lib-smtp/smtp-syntax.c
index 6826682af1..0b0a91ce07 100644
--- a/src/lib-smtp/smtp-syntax.c
+++ b/src/lib-smtp/smtp-syntax.c
@@ -86,20 +86,20 @@ int smtp_xtext_parse(const char *xtext,
 {
 	struct smtp_parser parser;
 	string_t *value = NULL;
-	int ret;
+
+	*value_r = NULL;
+	*error_r = NULL;
 
 	if (xtext == NULL || *xtext == '\0') {
 		*value_r = "";
 		return 1;
 	}
 
-	if (value_r != NULL)
-		value = t_str_new(256);
+	value = t_str_new(256);
 	smtp_parser_init(&parser, pool_datastack_create(), xtext);
 
-	if ((ret=smtp_parser_parse_xtext(&parser, value)) < 0) {
-		if (error_r != NULL)
-			*error_r = parser.error;
+	if (smtp_parser_parse_xtext(&parser, value) < 0) {
+		*error_r = parser.error;
 		return -1;
 	}
 	if (parser.cur < parser.end) {
@@ -110,8 +110,7 @@ int smtp_xtext_parse(const char *xtext,
 	if (value_r != NULL) {
 		*value_r = str_c(value);
 		if (strlen(*value_r) != str_len(value)) {
-			if (*error_r != NULL)
-				*error_r = "Encountered NUL character in xtext";
+			*error_r = "Encountered NUL character in xtext";
 			return -1;
 		}
 	}
-- 
2.11.0

openSUSE Build Service is sponsored by