From: Timo Sirainen Date: Thu, 27 Mar 2025 10:23:30 +0000 (+0200) Subject: imap: Fix potential assert-crash if pipelining IDLE+DONE+more commands X-Git-Tag: 2.4.2~868 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=60d431a0cc0890dbddcea121ddb3eee7ac001354;p=thirdparty%2Fdovecot%2Fcore.git imap: Fix potential assert-crash if pipelining IDLE+DONE+more commands At least followed by COPY command it assert-crashes. Fixes: Panic: file cmd-copy.c: line 120 (fetch_and_copy): assertion failed: (o_stream_is_corked(client->output) || client->output->stream_errno != 0) --- diff --git a/src/imap/cmd-idle.c b/src/imap/cmd-idle.c index e1f492779a..538082f937 100644 --- a/src/imap/cmd-idle.c +++ b/src/imap/cmd-idle.c @@ -36,6 +36,7 @@ idle_finish(struct cmd_idle_context *ctx, bool done_ok, bool free_cmd) (void)imap_sync_deinit(ctx->sync_ctx, ctx->cmd); } + bool orig_corked = o_stream_is_corked(client->output); o_stream_cork(client->output); io_remove(&client->io); @@ -47,7 +48,8 @@ idle_finish(struct cmd_idle_context *ctx, bool done_ok, bool free_cmd) else client_send_tagline(ctx->cmd, "BAD Expected DONE."); - o_stream_uncork(client->output); + if (!orig_corked) + o_stream_uncork(client->output); if (free_cmd) client_command_free(&ctx->cmd); }