]> 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)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 20 May 2020 05:26:26 +0000 (05:26 +0000)
src/lib-smtp/smtp-syntax.c

index b62de7ea36b544b685cdc480b1852f595b83b349..25f52c1deab20fda50cac8a49898515c65c92525 100644 (file)
@@ -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;
                }
        }