From 9a00369c8a09ccb2799dd6b3a4767947f5ace55a Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Mon, 14 Oct 2024 12:53:33 +0300 Subject: [PATCH] imap: Fix potential hang/crash when unhibernating This fixes two potential bugs: a) Unhibernation is triggered by new mailbox changes. While sending these to IMAP client, Dovecot notices that the client has disconnected. The process will stay IDLEing for 30 minutes until it gets disconnected with "Disconnected: Inactivity - no input for 1800 secs" b) Unhibernation is triggered by DONE command with some further pipelined commands. During unhibernation new mailbox changes are noticed, and again IMAP client is found to be disconnected while sending the changes. This causes a segfault. --- src/imap/cmd-idle.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/imap/cmd-idle.c b/src/imap/cmd-idle.c index 2b31dc714e..e1f492779a 100644 --- a/src/imap/cmd-idle.c +++ b/src/imap/cmd-idle.c @@ -302,7 +302,9 @@ bool cmd_idle(struct client_command_context *cmd) /* check immediately if there are changes. if they came before we added mailbox-notifier, we wouldn't see them otherwise. */ - if (client->mailbox != NULL) - idle_sync_now(client->mailbox, ctx); + if (client->mailbox != NULL) { + if (idle_sync_now(client->mailbox, ctx)) + return TRUE; + } return idle_client_handle_input(ctx, FALSE); } -- 2.47.3