dovecot-1.2: imap: Don't crash with QRESYNC SELECT specifying se...

dovecot at dovecot.org dovecot at dovecot.org
Thu Aug 19 20:36:35 EEST 2010


details:   http://hg.dovecot.org/dovecot-1.2/rev/70fa6178380e
changeset: 9601:70fa6178380e
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Aug 19 18:36:09 2010 +0100
description:
imap: Don't crash with QRESYNC SELECT specifying sequences larger than mailbox's message count.

diffstat:

 src/imap/imap-fetch.c |  5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diffs (23 lines):

diff -r ccc71865dea0 -r 70fa6178380e src/imap/imap-fetch.c
--- 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;


More information about the dovecot-cvs mailing list