From 940307ae2c5937be010937ff3d66195c86f467df Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 29 Oct 2020 12:55:21 +0200 Subject: [PATCH] imap: Fix potential hang if client disconnects with pipelined ambiguous commands For example if client pipelines FETCH+LOGOUT commands and disconnects during a large FETCH output, the LOGOUT command is processed as waiting for unambiguity. This code path however doesn't detect a client disconnection, and input IO handler is removed so it can't detect it either. So the imap process hangs. --- src/imap/imap-client.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/imap/imap-client.c b/src/imap/imap-client.c index e617979738..f29f01061f 100644 --- a/src/imap/imap-client.c +++ b/src/imap/imap-client.c @@ -1117,7 +1117,9 @@ void client_continue_pending_input(struct client *client) if (!ret) break; } - if (!client->input->closed && !client->output->closed) + if (client->input->closed || client->output->closed) + client_destroy(client, NULL); + else client_check_command_hangs(client); } -- 2.47.3