dovecot-2.0: maildir: Fixed potential assert-crashes with "Dupli...

dovecot at dovecot.org dovecot at dovecot.org
Wed Dec 23 20:04:02 EET 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/c8322124d615
changeset: 10529:c8322124d615
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Dec 23 13:03:56 2009 -0500
description:
maildir: Fixed potential assert-crashes with "Duplicate file entry" handling.

diffstat:

1 file changed, 14 insertions(+), 7 deletions(-)
src/lib-storage/index/maildir/maildir-uidlist.c |   21 ++++++++++++++-------

diffs (31 lines):

diff -r f011d7801572 -r c8322124d615 src/lib-storage/index/maildir/maildir-uidlist.c
--- a/src/lib-storage/index/maildir/maildir-uidlist.c	Wed Dec 23 12:26:39 2009 -0500
+++ b/src/lib-storage/index/maildir/maildir-uidlist.c	Wed Dec 23 13:03:56 2009 -0500
@@ -400,13 +400,20 @@ maildir_uidlist_records_array_delete(str
 				     struct maildir_uidlist_rec *rec)
 {
 	struct maildir_uidlist_rec *const *recs, *const *pos;
-	unsigned int idx;
-
-	pos = array_bsearch(&uidlist->records, &rec, maildir_uid_cmp);
-	i_assert(pos != NULL);
-
-	recs = array_idx(&uidlist->records, 0);
-	idx = pos - recs;
+	unsigned int idx, count;
+
+	recs = array_get(&uidlist->records, &count);
+	if (!uidlist->unsorted) {
+		pos = array_bsearch(&uidlist->records, &rec, maildir_uid_cmp);
+		i_assert(pos != NULL);
+		idx = pos - recs;
+	} else {
+		for (idx = 0; idx < count; idx++) {
+			if (recs[idx]->uid == rec->uid)
+				break;
+		}
+		i_assert(idx != count);
+	}
 	array_delete(&uidlist->records, idx, 1);
 	return idx;
 }


More information about the dovecot-cvs mailing list