]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: smtp-syntax - Do not allow NULL return parameters for smtp_string_parse().
authorStephan Bosch <stephan.bosch@open-xchange.com>
Tue, 24 Mar 2020 19:57:03 +0000 (20:57 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 20 May 2020 05:26:26 +0000 (05:26 +0000)
src/lib-smtp/smtp-server-cmd-noop.c
src/lib-smtp/smtp-syntax.c

index e798a5798565cfff259a99cb0f385d7205ceeaf3..86e426f35befead2c260b94782d437b00c97d113 100644 (file)
@@ -13,11 +13,15 @@ void smtp_server_cmd_noop(struct smtp_server_cmd_ctx *cmd,
        struct smtp_server_connection *conn = cmd->conn;
        struct smtp_server_command *command = cmd->cmd;
        const struct smtp_server_callbacks *callbacks = conn->callbacks;
+       const char *param, *error;
        int ret;
 
        /* "NOOP" [ SP String ] CRLF */
-       if (*params != '\0' && smtp_string_parse(params, NULL, NULL) < 0) {
-               smtp_server_reply(cmd, 501, "5.5.4", "Invalid parameters");
+       ret = smtp_string_parse(params, &param, &error);
+       if (ret < 0) {
+               smtp_server_reply(cmd, 501, "5.5.4",
+                                 "Invalid string parameter: %s",
+                                 error);
                return;
        }
 
index ce53f30deecebff3fc9418e7b3bf9ee7a049c4b6..b62de7ea36b544b685cdc480b1852f595b83b349 100644 (file)
@@ -18,6 +18,9 @@ int smtp_string_parse(const char *string, const char **value_r,
 {
        struct smtp_parser parser;
 
+       *value_r = NULL;
+       *error_r = NULL;
+
        if (string == NULL || *string == '\0') {
                *value_r = "";
                return 1;
@@ -26,8 +29,7 @@ int smtp_string_parse(const char *string, const char **value_r,
        smtp_parser_init(&parser, pool_datastack_create(), string);
 
        if (smtp_parser_parse_string(&parser, value_r) < 0) {
-               if (error_r != NULL)
-                       *error_r = parser.error;
+               *error_r = parser.error;
                return -1;
        }
        if (parser.cur < parser.end) {