]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Fix crash when trying to use COMPRESS multiple times
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 30 May 2023 08:10:39 +0000 (11:10 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 30 May 2023 08:21:12 +0000 (11:21 +0300)
Broken by 5f27e25c64555dcaae6cb00c479cd05bc2638081

Fixes:
Panic: file cmd-compress.c: line 104 (cmd_compress): assertion failed: (client->input->v_offset == prev_in_offset)

src/imap/cmd-compress.c
src/imap/imap-client.h

index 00fb36ff4836d9181109d13e2e154f83a7746359..52c74b5a8214e159e512bdf4d6a29b2f61d035e5 100644 (file)
@@ -59,6 +59,12 @@ bool cmd_compress(struct client_command_context *cmd)
                return TRUE;
        }
 
+       if (client->compress_handler != NULL) {
+               client_send_tagline(cmd, t_strdup_printf(
+                       "NO [COMPRESSIONACTIVE] COMPRESSION=%s already enabled.",
+                       t_str_ucase(client->compress_handler->name)));
+               return TRUE;
+       }
        int ret = compression_lookup_handler(t_str_lcase(mechanism), &handler);
        if (ret <= 0) {
                const char * tagline =
@@ -121,5 +127,6 @@ bool cmd_compress(struct client_command_context *cmd)
        }
 
        client_update_imap_parser_streams(client);
+       client->compress_handler = handler;
        return TRUE;
 }
index ad1e6f5c5dd5373aabe6039d88e1ded9dde30477..194d7aa0596a2f3b87e101298c2e89da97713c58 100644 (file)
@@ -212,6 +212,8 @@ struct client {
        /* NOTIFY extension */
        struct imap_notify_context *notify_ctx;
        uint32_t notify_uidnext;
+       /* COMPRESS extension */
+       const struct compression_handler *compress_handler;
 
        /* client input/output is locked by this command */
        struct client_command_context *input_lock;