aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJiri Hruska <jirka@fud.cz>2013-02-26 22:12:24 +0100
committerSteve Holme <steve_holme@hotmail.com>2013-02-26 22:09:21 +0000
commita8eb059203ffbe41ea9519d28cee916eb5e02790 (patch)
tree24717b14e8b1b8cb2c0b6a6ec2b4a4cd68ac4692 /lib
parent59c71c7fc7b75cb7f6680e2ef269477831c215e6 (diff)
imap: Added verification of UIDVALIDITY mailbox attribute
Added support for checking the UIDVALIDITY, and aborting the request, if it has been specified in the URL and the server response is different.
Diffstat (limited to 'lib')
-rw-r--r--lib/imap.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/imap.c b/lib/imap.c
index b7c92ef58..9f0e6cb95 100644
--- a/lib/imap.c
+++ b/lib/imap.c
@@ -1216,6 +1216,7 @@ static CURLcode imap_state_select_resp(struct connectdata *conn,
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
+ struct IMAP *imap = conn->data->state.proto.imap;
struct imap_conn *imapc = &conn->proto.imapc;
const char *line = data->state.buffer;
char tmp[20];
@@ -1233,8 +1234,16 @@ static CURLcode imap_state_select_resp(struct connectdata *conn,
failf(data, "Select failed");
result = CURLE_LOGIN_DENIED;
}
- else
- result = imap_fetch(conn);
+ else {
+ /* Check if the UIDVALIDITY has been specified and matches */
+ if(imap->uidvalidity && imapc->mailbox_uidvalidity &&
+ strcmp(imap->uidvalidity, imapc->mailbox_uidvalidity)) {
+ failf(conn->data, "Mailbox UIDVALIDITY has changed");
+ result = CURLE_REMOTE_FILE_NOT_FOUND;
+ }
+ else
+ result = imap_fetch(conn);
+ }
return result;
}