From 0ff8b7fd6b7021a845538f6bcf755d97d488fddb Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 19 Dec 2013 21:37:28 +0200 Subject: [PATCH] imap: If any FETCH/STORE tries to access modseqs when NOMODSEQ was returned, return BAD. --- src/imap/cmd-fetch.c | 5 +++++ src/imap/cmd-store.c | 5 +++++ src/imap/imap-fetch.c | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/src/imap/cmd-fetch.c b/src/imap/cmd-fetch.c index 36cf2a6f4e..dc1b9039b6 100644 --- a/src/imap/cmd-fetch.c +++ b/src/imap/cmd-fetch.c @@ -111,6 +111,11 @@ fetch_parse_modifier(struct imap_fetch_context *ctx, uint64_t modseq; if (strcmp(name, "CHANGEDSINCE") == 0) { + if (cmd->client->nonpermanent_modseqs) { + client_send_command_error(cmd, + "FETCH CHANGEDSINCE can't be used with non-permanent modseqs"); + return FALSE; + } if (!imap_arg_get_atom(*args, &str) || str_to_uint64(str, &modseq) < 0) { client_send_command_error(cmd, diff --git a/src/imap/cmd-store.c b/src/imap/cmd-store.c index 7a187e475c..d5f713aaac 100644 --- a/src/imap/cmd-store.c +++ b/src/imap/cmd-store.c @@ -57,6 +57,11 @@ store_parse_modifiers(struct imap_store_context *ctx, } if (strcasecmp(name, "UNCHANGEDSINCE") == 0) { + if (ctx->cmd->client->nonpermanent_modseqs) { + client_send_command_error(ctx->cmd, + "STORE UNCHANGEDSINCE can't be used with non-permanent modseqs"); + return FALSE; + } if (str_to_uint64(value, &ctx->max_modseq) < 0) { client_send_command_error(ctx->cmd, "Invalid modseq"); diff --git a/src/imap/imap-fetch.c b/src/imap/imap-fetch.c index c2796f6cfc..1470a54e04 100644 --- a/src/imap/imap-fetch.c +++ b/src/imap/imap-fetch.c @@ -804,6 +804,10 @@ static int fetch_modseq(struct imap_fetch_context *ctx, struct mail *mail, bool imap_fetch_modseq_init(struct imap_fetch_init_context *ctx) { + if (ctx->fetch_ctx->client->nonpermanent_modseqs) { + ctx->error = "FETCH MODSEQ can't be used with non-permanent modseqs"; + return FALSE; + } (void)client_enable(ctx->fetch_ctx->client, MAILBOX_FEATURE_CONDSTORE); imap_fetch_add_handler(ctx, IMAP_FETCH_HANDLER_FLAG_BUFFERED, NULL, fetch_modseq, NULL); -- 2.47.3