]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: smtp-syntax - Do not allow NULL return parameters for smtp_xtext_parse().
authorStephan Bosch <stephan.bosch@open-xchange.com>
Tue, 24 Mar 2020 20:11:01 +0000 (21:11 +0100)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 1 Apr 2020 08:49:24 +0000 (11:49 +0300)
src/lib-smtp/smtp-syntax.c

index 6826682af1e7f8c567848a3a5d2ecdc94bb45a52..0b0a91ce07cfac99462a2ba422731d001dbeeb01 100644 (file)
@@ -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;
                }
        }