Skip to content

Commit

Permalink
imap-hibernate: Fix "DONE" handling.
Browse files Browse the repository at this point in the history
1. If only "DONE\r\n" was sent, it randomly failed with BAD because of
out-of-bounds buffer read.

2. If "DONE\r\n" was followed by a command tag but no space afterwards, we
kept waiting for the input to continue. But since the DONE was already sent,
we should break the IDLE already at that point without any further waiting.
  • Loading branch information
sirainen authored and GitLab committed Oct 21, 2016
1 parent e8a936d commit 28f7995
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/imap-hibernate/imap-client.c
Expand Up @@ -278,6 +278,8 @@ imap_client_input_parse(const unsigned char *data, size_t size, const char **tag
if (data[0] != '\n')
return IMAP_CLIENT_INPUT_STATE_BAD;
data++; size--;
if (size == 0)
return state;

tag_start = data;

Expand All @@ -289,7 +291,7 @@ imap_client_input_parse(const unsigned char *data, size_t size, const char **tag
tag_end = data;

if (size == 0)
return IMAP_CLIENT_INPUT_STATE_UNKNOWN;
return state;
if (data[0] != ' ')
return IMAP_CLIENT_INPUT_STATE_BAD;
data++; size--;
Expand Down

0 comments on commit 28f7995

Please sign in to comment.