Skip to content

Commit

Permalink
imap-hibernate: Accept RFC DONE\IDLE
Browse files Browse the repository at this point in the history
Change imap-hibernate to accept
DONE\r\n<tag> IDLE\r\n
as well, which is specified by RFC
  • Loading branch information
cmouse committed Sep 28, 2016
1 parent f6f50f5 commit a751226
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/imap-hibernate/imap-client.c
Expand Up @@ -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. */
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a751226

Please sign in to comment.