[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-sync-parse.c, 1.49.2.3, 1.49.2.4

tss at dovecot.org tss at dovecot.org
Thu Jan 25 09:38:23 UTC 2007


Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv7594

Modified Files:
      Tag: branch_1_0
	mbox-sync-parse.c 
Log Message:
When verifying a mail's location in dirty mbox with invalid X-UID headers
that weren't yet rewritten, we would trust the X-UID header and cause the
verification to fail. Now we trust it only if it's valid, otherwise fallback
to MD5 sum of the header.



Index: mbox-sync-parse.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-parse.c,v
retrieving revision 1.49.2.3
retrieving revision 1.49.2.4
diff -u -d -r1.49.2.3 -r1.49.2.4
--- mbox-sync-parse.c	22 Jan 2007 12:10:18 -0000	1.49.2.3
+++ mbox-sync-parse.c	25 Jan 2007 09:38:21 -0000	1.49.2.4
@@ -553,8 +553,15 @@
 	int ret;
 
 	/* we only wish to be sure that this mail actually is what we expect
-	   it to be. If there's X-UID header, it's used. Otherwise use
-	   the MD5 sum. */
+	   it to be. If there's X-UID header and it matches our UID, we use it.
+	   Otherwise it could mean that the X-UID header is invalid and it's
+	   just not yet been rewritten. In that case use MD5 sum, if it
+	   exists. */
+
+	if (mail_index_lookup_uid(view, seq, &uid) < 0) {
+		mail_storage_set_index_error(&mbox->ibox);
+		return -1;
+	}
 
 	memset(&ctx, 0, sizeof(ctx));
         mbox_md5_ctx = mbox_md5_init();
@@ -575,7 +582,7 @@
 				}
 				(void)parse_x_uid(&ctx, hdr);
 
-				if (ctx.mail.uid != 0)
+				if (ctx.mail.uid == uid)
 					break;
 			}
 		} else {
@@ -587,14 +594,8 @@
 
 	mbox_md5_finish(mbox_md5_ctx, ctx.hdr_md5_sum);
 
-	if (ctx.mail.uid != 0) {
-		/* match by X-UID header */
-		if (mail_index_lookup_uid(view, seq, &uid) < 0) {
-			mail_storage_set_index_error(&mbox->ibox);
-			return -1;
-		}
-		return ctx.mail.uid == uid;
-	}
+	if (ctx.mail.uid == uid)
+		return TRUE;
 
 	/* match by MD5 sum */
 	mbox->mbox_save_md5 = TRUE;



More information about the dovecot-cvs mailing list