]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: smtp-server-command - Fix segfault occurring in smtp_server_command_get_rep...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 16 Mar 2019 13:53:26 +0000 (14:53 +0100)
committerStephan Bosch <stephan.bosch@dovecot.fi>
Mon, 18 Mar 2019 21:25:45 +0000 (22:25 +0100)
Can occur when not all replies are submitted yet.

src/lib-smtp/smtp-server-command.c

index 79fbe12631a57bedad8b31ed19e6217b00620a7b..f898728fdd72a58df7c3c1b93999c596857bab4c 100644 (file)
@@ -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;