dovecot-2.2: dsync: Verify messages' GUIDs better.

dovecot at dovecot.org dovecot at dovecot.org
Mon Jan 21 16:57:55 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/f0dbe8fc8905
changeset: 15657:f0dbe8fc8905
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Jan 21 16:52:49 2013 +0200
description:
dsync: Verify messages' GUIDs better.

diffstat:

 src/doveadm/dsync/dsync-mailbox-import.c |  25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

diffs (50 lines):

diff -r 4260de42d93c -r f0dbe8fc8905 src/doveadm/dsync/dsync-mailbox-import.c
--- a/src/doveadm/dsync/dsync-mailbox-import.c	Mon Jan 21 16:44:33 2013 +0200
+++ b/src/doveadm/dsync/dsync-mailbox-import.c	Mon Jan 21 16:52:49 2013 +0200
@@ -432,6 +432,22 @@
 	return TRUE;
 }
 
+static bool dsync_check_cur_guid(struct dsync_mailbox_importer *importer,
+				 const struct dsync_mail_change *change)
+{
+	if (change->guid == NULL || *change->guid == '\0')
+		return TRUE;
+	if (strcmp(importer->cur_guid, change->guid) != 0) {
+		i_error("Mailbox %s: Unexpected GUID mismatch for "
+			"UID=%u: %s != %s", mailbox_get_vname(importer->box),
+			change->uid, importer->cur_guid, change->guid);
+		importer->last_common_uid = 1;
+		importer->failed = TRUE;
+		return FALSE;
+	}
+	return TRUE;
+}
+
 static void
 merge_flags(uint32_t local_final, uint32_t local_add, uint32_t local_remove,
 	    uint32_t remote_final, uint32_t remote_add, uint32_t remote_remove,
@@ -718,9 +734,11 @@
 	i_assert((change->add_flags & change->remove_flags) == 0);
 
 	if (importer->cur_mail != NULL &&
-	    importer->cur_mail->uid == change->uid)
+	    importer->cur_mail->uid == change->uid) {
+		if (!dsync_check_cur_guid(importer, change))
+			return;
 		mail = importer->cur_mail;
-	else {
+	} else {
 		if (!dsync_import_set_mail(importer, change))
 			return;
 		mail = importer->mail;
@@ -833,7 +851,8 @@
 	} else if (change->uid == importer->last_common_uid) {
 		/* already verified that the GUID matches */
 		i_assert(importer->cur_mail->uid == change->uid);
-		mail_expunge(importer->cur_mail);
+		if (dsync_check_cur_guid(importer, change))
+			mail_expunge(importer->cur_mail);
 	} else {
 		/* we don't know yet if we should expunge this
 		   message or not. queue it until we do. */


More information about the dovecot-cvs mailing list