]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap-hibernate: Accept RFC DONE\IDLE
authorAki Tuomi <aki.tuomi@dovecot.fi>
Wed, 28 Sep 2016 10:34:46 +0000 (13:34 +0300)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Wed, 28 Sep 2016 11:30:05 +0000 (14:30 +0300)
Change imap-hibernate to accept
DONE\r\n<tag> IDLE\r\n
as well, which is specified by RFC

src/imap-hibernate/imap-client.c

index 7c91e2ea00be8cb37bef5b70dfb5233b230dc62d..a151b730ede9a549a77f45735ef45945b98ac52e 100644 (file)
@@ -26,8 +26,8 @@
 
 #define IMAP_MASTER_SOCKET_NAME "imap-master"
 
-/* we only need enough for "DONE\r\nIDLE\r\n" */
-#define IMAP_MAX_INBUF 12
+/* we only need enough for "DONE\r\n<tag> IDLE\r\n" */
+#define IMAP_MAX_INBUF 12 + 1 + 128 /* DONE\r\nIDLE\r\n + ' ' + <tag> */
 
 /* If client has sent input and we can't recreate imap process in this
    many seconds, disconnect the client. */
@@ -267,6 +267,17 @@ imap_client_input_parse(const unsigned char *data, size_t size)
                return IMAP_CLIENT_INPUT_STATE_BAD;
        data++; size--;
 
+       /* skip over tag */
+       while(size > 6 &&
+             data[0] != ' ' &&
+             data[0] != '\r' &&
+             data[0] != '\t' ) { data++; size--; }
+
+       if (size == 0)
+               return IMAP_CLIENT_INPUT_STATE_UNKNOWN;
+       if (data[0] != ' ')
+               return IMAP_CLIENT_INPUT_STATE_BAD;
+
        /* skip over IDLE[\r]\n - checking this assumes that the DONE and IDLE
           are sent in the same IP packet, otherwise we'll unnecessarily
           recreate the imap process and immediately resume IDLE there. if this