]> 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)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 1 Apr 2020 08:49:24 +0000 (11:49 +0300)
src/lib-smtp/smtp-server-cmd-noop.c
src/lib-smtp/smtp-syntax.c

index 4986f800c844964df6594fc39006db69dc819fc1..550d709eabed35cea01971d81db326da3424fdad 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 5d22445f7283b635204f5bb8969bf9910f41097d..6826682af1e7f8c567848a3a5d2ecdc94bb45a52 100644 (file)
@@ -17,7 +17,9 @@ int smtp_string_parse(const char *string,
        const char **value_r, const char **error_r)
 {
        struct smtp_parser parser;
-       int ret;
+
+       *value_r = NULL;
+       *error_r = NULL;
 
        if (string == NULL || *string == '\0') {
                *value_r = "";
@@ -26,9 +28,8 @@ int smtp_string_parse(const char *string,
 
        smtp_parser_init(&parser, pool_datastack_create(), string);
 
-       if ((ret=smtp_parser_parse_string(&parser, value_r)) < 0) {
-               if (error_r != NULL)
-                       *error_r = parser.error;
+       if (smtp_parser_parse_string(&parser, value_r) < 0) {
+               *error_r = parser.error;
                return -1;
        }
        if (parser.cur < parser.end) {