dovecot: Make sure that uid < next_uid if uidlist version is 1.

dovecot at dovecot.org dovecot at dovecot.org
Thu Jul 12 04:24:30 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/5825961b9862
changeset: 5958:5825961b9862
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jul 12 04:24:22 2007 +0300
description:
Make sure that uid < next_uid if uidlist version is 1.

diffstat:

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

diffs (31 lines):

diff -r 874428d05272 -r 5825961b9862 src/lib-storage/index/maildir/maildir-uidlist.c
--- a/src/lib-storage/index/maildir/maildir-uidlist.c	Thu Jul 12 04:24:00 2007 +0300
+++ b/src/lib-storage/index/maildir/maildir-uidlist.c	Thu Jul 12 04:24:22 2007 +0300
@@ -324,6 +324,13 @@ static int maildir_uidlist_next(struct m
 	}
         uidlist->last_seen_uid = uid;
 
+	if (uid >= uidlist->next_uid && uidlist->version == 1) {
+		mail_storage_set_critical(storage,
+			"UID larger than next_uid in file %s (%u >= %u)",
+			uidlist->path, uid, uidlist->next_uid);
+		return 0;
+	}
+
 	rec = p_new(uidlist->record_pool, struct maildir_uidlist_rec, 1);
 	rec->uid = uid;
 	rec->flags = MAILDIR_UIDLIST_REC_FLAG_NONSYNCED;
@@ -383,6 +390,13 @@ static int maildir_uidlist_read_header(s
 			mail_storage_set_critical(storage,
 				"%s: Corrupted header (version 1)",
 				uidlist->path);
+			return 0;
+		}
+		if (uid_validity == uidlist->uid_validity &&
+		    next_uid < uidlist->next_uid) {
+			mail_storage_set_critical(storage,
+				"%s: next_uid was lowered (v1, %u -> %u)",
+				uidlist->path, uidlist->next_uid, next_uid);
 			return 0;
 		}
 		break;


More information about the dovecot-cvs mailing list