From: Stephan Bosch Date: Tue, 24 Mar 2020 20:11:01 +0000 (+0100) Subject: lib-smtp: smtp-syntax - Do not allow NULL return parameters for smtp_xtext_parse(). X-Git-Tag: 2.3.11.2~85 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=544060fb533445f4dba26ed002a9bb8a08a4581c;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: smtp-syntax - Do not allow NULL return parameters for smtp_xtext_parse(). --- diff --git a/src/lib-smtp/smtp-syntax.c b/src/lib-smtp/smtp-syntax.c index b62de7ea36..25f52c1dea 100644 --- a/src/lib-smtp/smtp-syntax.c +++ b/src/lib-smtp/smtp-syntax.c @@ -87,18 +87,19 @@ int smtp_xtext_parse(const char *xtext, const char **value_r, struct smtp_parser parser; string_t *value = NULL; + *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 (smtp_parser_parse_xtext(&parser, value) < 0) { - if (error_r != NULL) - *error_r = parser.error; + *error_r = parser.error; return -1; } if (parser.cur < parser.end) { @@ -109,8 +110,7 @@ int smtp_xtext_parse(const char *xtext, const char **value_r, 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; } }