From: Stephan Bosch Date: Sat, 16 Mar 2019 13:53:26 +0000 (+0100) Subject: lib-smtp: smtp-server-command - Fix segfault occurring in smtp_server_command_get_rep... X-Git-Tag: 2.3.9~635 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d3ddff1bc53ce80a512bee1cb8ea56503616409;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: smtp-server-command - Fix segfault occurring in smtp_server_command_get_reply(). Can occur when not all replies are submitted yet. --- diff --git a/src/lib-smtp/smtp-server-command.c b/src/lib-smtp/smtp-server-command.c index 79fbe12631..f898728fdd 100644 --- a/src/lib-smtp/smtp-server-command.c +++ b/src/lib-smtp/smtp-server-command.c @@ -609,10 +609,12 @@ smtp_server_command_get_reply(struct smtp_server_command *cmd, { struct smtp_server_reply *reply; + i_assert(idx < cmd->replies_expected); + if (!array_is_created(&cmd->replies)) return NULL; - reply = array_idx_modifiable(&cmd->replies, idx); + reply = array_idx_get_space(&cmd->replies, idx); if (!reply->submitted) return NULL; return reply;