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

dovecot at dovecot.org dovecot at dovecot.org
Wed Dec 23 20:03:01 EET 2009


details:   http://hg.dovecot.org/dovecot-1.2/rev/d00abdaf9df2
changeset: 9519:d00abdaf9df2
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Dec 23 13:02:55 2009 -0500
description:
maildir: Fixed potential assert-crashes with "Duplicate file entry" handling.

diffstat:

1 file changed, 12 insertions(+), 4 deletions(-)
src/lib-storage/index/maildir/maildir-uidlist.c |   16 ++++++++++++----

diffs (26 lines):

diff -r ef7b42b237bd -r d00abdaf9df2 src/lib-storage/index/maildir/maildir-uidlist.c
--- a/src/lib-storage/index/maildir/maildir-uidlist.c	Tue Dec 22 18:22:43 2009 -0500
+++ b/src/lib-storage/index/maildir/maildir-uidlist.c	Wed Dec 23 13:02:55 2009 -0500
@@ -399,10 +399,18 @@ maildir_uidlist_records_array_delete(str
 	unsigned int idx, count;
 
 	recs = array_get(&uidlist->records, &count);
-	pos = bsearch(&rec, recs, count, sizeof(*recs), maildir_uid_cmp);
-	i_assert(pos != NULL);
-
-	idx = pos - recs;
+	if (!uidlist->unsorted) {
+		pos = bsearch(&rec, recs, count, sizeof(*recs),
+			      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