]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Fix command ambiguity checking with special plugins
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 6 Aug 2018 09:39:25 +0000 (12:39 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Tue, 13 Nov 2018 11:29:12 +0000 (13:29 +0200)
If the tagged line is already sent, that command can't result in ambiguity
anymore.

A cleaner fix would be to add a new _WAIT_SYNC_OUTPUT state, but that
requires all the existing code to understand that new state correctly, so it
has a higher chance of breaking something. So at least for now don't add it.

src/imap/imap-client.c

index baa468374daf29a893ce88ac8c89a006d82eb98d..80b24e787741538965e75288f8a2131ea4851f8e 100644 (file)
@@ -785,7 +785,13 @@ client_command_find_with_flags(struct client_command_context *new_cmd,
 
        cmd = new_cmd->client->command_queue;
        for (; cmd != NULL; cmd = cmd->next) {
-               if (cmd->state <= max_state &&
+               /* The tagline_sent check is a bit kludgy here. Plugins may
+                  hook into sync_notify_more() and send the tagline before
+                  finishing the command. During this stage the state was been
+                  dropped from _WAIT_SYNC to _WAIT_OUTPUT, so the <= max_state
+                  check doesn't work correctly here. (Perhaps we should add
+                  a new _WAIT_SYNC_OUTPUT?) */
+               if (cmd->state <= max_state && !cmd->tagline_sent &&
                    cmd != new_cmd && (cmd->cmd_flags & flags) != 0)
                        return cmd;
        }