Mercurial > dovecot > original-hg > dovecot-1.2
changeset 9601:70fa6178380e HEAD
imap: Don't crash with QRESYNC SELECT specifying sequences larger than mailbox's message count.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 19 Aug 2010 18:36:09 +0100 |
parents | ccc71865dea0 |
children | cc7aa7a4dd6d |
files | src/imap/imap-fetch.c |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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;