From: Stephan Bosch Date: Tue, 24 Mar 2020 19:57:03 +0000 (+0100) Subject: lib-smtp: smtp-syntax - Do not allow NULL return parameters for smtp_string_parse(). X-Git-Tag: 2.3.11.2~86 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=86544123628006233f06938d315ee0266deb3d8c;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: smtp-syntax - Do not allow NULL return parameters for smtp_string_parse(). --- diff --git a/src/lib-smtp/smtp-server-cmd-noop.c b/src/lib-smtp/smtp-server-cmd-noop.c index e798a57985..86e426f35b 100644 --- a/src/lib-smtp/smtp-server-cmd-noop.c +++ b/src/lib-smtp/smtp-server-cmd-noop.c @@ -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, ¶m, &error); + if (ret < 0) { + smtp_server_reply(cmd, 501, "5.5.4", + "Invalid string parameter: %s", + error); return; } diff --git a/src/lib-smtp/smtp-syntax.c b/src/lib-smtp/smtp-syntax.c index ce53f30dee..b62de7ea36 100644 --- a/src/lib-smtp/smtp-syntax.c +++ b/src/lib-smtp/smtp-syntax.c @@ -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) {