Skip to content

Commit

Permalink
lib-smtp: server: Fix overwriting a previously submitted reply.
Browse files Browse the repository at this point in the history
The submitted flag was not reset, nor was the replies_submitted counter
decreased. This caused assertion failures.
  • Loading branch information
stephanbosch authored and sirainen committed Jan 29, 2018
1 parent 6e1bc1f commit def7173
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/lib-smtp/smtp-server-reply.c
Expand Up @@ -50,7 +50,7 @@ smtp_server_reply_debug(struct smtp_server_reply *reply,
* Reply
*/

static void smtp_server_reply_clear(struct smtp_server_reply *reply)
static void smtp_server_reply_destroy(struct smtp_server_reply *reply)
{
if (reply->command == NULL)
return;
Expand All @@ -62,6 +62,16 @@ static void smtp_server_reply_clear(struct smtp_server_reply *reply)
str_free(&reply->content->text);
}

static void smtp_server_reply_clear(struct smtp_server_reply *reply)
{
smtp_server_reply_destroy(reply);
if (reply->submitted) {
i_assert(reply->command->replies_submitted > 0);
reply->command->replies_submitted--;
}
reply->submitted = FALSE;
}

static struct smtp_server_reply *
smtp_server_reply_alloc(struct smtp_server_command *cmd, unsigned int index)
{
Expand Down Expand Up @@ -160,7 +170,7 @@ void smtp_server_reply_free(struct smtp_server_command *cmd)
for (i = 0; i < cmd->replies_expected; i++) {
struct smtp_server_reply *reply =
array_idx_modifiable(&cmd->replies, i);
smtp_server_reply_clear(reply);
smtp_server_reply_destroy(reply);
}
}

Expand Down

0 comments on commit def7173

Please sign in to comment.