aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Hruska <jirka@fud.cz>2013-02-24 14:54:25 +0100
committerSteve Holme <steve_holme@hotmail.com>2013-02-24 14:38:54 +0000
commit671f896c0b6aef37fd57c6fb702275d8ad6bade0 (patch)
treed36d554dad919c30c25f7b59aa5b3ebf0235a605
parent7f5824a106b926b46ebfd3d4963d9508f0fd62d1 (diff)
imap: Added stricter parsing of continuation responses
Enhanced the parsing to only allow continuation responses in some states.
-rw-r--r--lib/imap.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/imap.c b/lib/imap.c
index 7d978b634..d135ba916 100644
--- a/lib/imap.c
+++ b/lib/imap.c
@@ -356,7 +356,25 @@ static bool imap_endofresp(struct connectdata *conn, char *line, size_t len,
/* Do we have a continuation response? */
if((len == 3 && !memcmp("+", line, 1)) ||
(len >= 2 && !memcmp("+ ", line, 2))) {
- *resp = '+';
+ switch(imapc->state) {
+ /* States which are interested in continuation responses */
+ case IMAP_AUTHENTICATE_PLAIN:
+ case IMAP_AUTHENTICATE_LOGIN:
+ case IMAP_AUTHENTICATE_LOGIN_PASSWD:
+ case IMAP_AUTHENTICATE_CRAMMD5:
+ case IMAP_AUTHENTICATE_DIGESTMD5:
+ case IMAP_AUTHENTICATE_DIGESTMD5_RESP:
+ case IMAP_AUTHENTICATE_NTLM:
+ case IMAP_AUTHENTICATE_NTLM_TYPE2MSG:
+ case IMAP_AUTHENTICATE:
+ *resp = '+';
+ break;
+
+ default:
+ failf(conn->data, "Unexpected continuation response");
+ *resp = -1;
+ break;
+ }
return TRUE;
}