From: Aki Tuomi Date: Wed, 28 Sep 2016 10:34:46 +0000 (+0300) Subject: imap-hibernate: Accept RFC DONE\IDLE X-Git-Tag: 2.3.0.rc1~2976 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a7512265bcded54af05e68e2383d11cb8638b513;p=thirdparty%2Fdovecot%2Fcore.git imap-hibernate: Accept RFC DONE\IDLE Change imap-hibernate to accept DONE\r\n IDLE\r\n as well, which is specified by RFC --- diff --git a/src/imap-hibernate/imap-client.c b/src/imap-hibernate/imap-client.c index 7c91e2ea00..a151b730ed 100644 --- a/src/imap-hibernate/imap-client.c +++ b/src/imap-hibernate/imap-client.c @@ -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 IDLE\r\n" */ +#define IMAP_MAX_INBUF 12 + 1 + 128 /* DONE\r\nIDLE\r\n + ' ' + */ /* 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