]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Fix potential assert-crash if pipelining IDLE+DONE+more commands
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 27 Mar 2025 10:23:30 +0000 (12:23 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Sat, 29 Mar 2025 08:27:28 +0000 (08:27 +0000)
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)

src/imap/cmd-idle.c

index e1f492779aaa16053733b843c744cd035489a140..538082f9377f146ef487345a8ed74768472da3e1 100644 (file)
@@ -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);
 }