# HG changeset patch
# User Timo Sirainen <tss@iki.fi>
# Date 1282239369 -3600
# Node ID 70fa6178380e508e8587a2e4633b2060378cae85
# Parent ccc71865dea0668a77d40b8d494e42b089a61942
imap: Don't crash with QRESYNC SELECT specifying sequences larger than mailbox's message count.
--- a/src/imap/imap-fetch.c Wed Aug 18 15:17:40 2010 +0100
+++ b/src/imap/imap-fetch.c Thu Aug 19 18:36:09 2010 +0100
@@ -165,6 +165,7 @@
expunges_drop_known(struct imap_fetch_context *ctx, struct mail *mail,
ARRAY_TYPE(seq_range) *expunged_uids)
{
+ struct mailbox_status status;
const uint32_t *seqs, *uids;
unsigned int i, count;
@@ -173,8 +174,10 @@
i_assert(array_count(ctx->qresync_sample_uidset) == count);
i_assert(count > 0);
+ mailbox_get_status(ctx->box, STATUS_MESSAGES, &status);
+
/* FIXME: we could do removals from the middle as well */
- for (i = 0; i < count; i++) {
+ for (i = 0; i < count && seqs[i] <= status.messages; i++) {
mail_set_seq(mail, seqs[i]);
if (uids[i] != mail->uid)
break;