]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mbox: Make sure we have valid mailbox GUID when returning it.
authorTimo Sirainen <tss@iki.fi>
Mon, 15 Feb 2010 05:08:40 +0000 (07:08 +0200)
committerTimo Sirainen <tss@iki.fi>
Mon, 15 Feb 2010 05:08:40 +0000 (07:08 +0200)
--HG--
branch : HEAD

src/lib-storage/index/mbox/mbox-storage.c
src/lib-storage/mail-storage.c

index 627a7cc29143b34e6013c8cf623163c16cdd95b8..7730bd9bb217af6d0331f8e9aea7e19b294cc667 100644 (file)
@@ -573,6 +573,10 @@ mbox_mailbox_get_guid(struct mailbox *box, uint8_t guid[MAIL_GUID_128_SIZE])
                        "Mailbox GUIDs are not permanent without index files");
                return -1;
        }
+       if (mail_guid_128_is_empty(mbox->mbox_hdr.mailbox_guid)) {
+               if (mailbox_sync(&mbox->box, 0) < 0)
+                       return -1;
+       }
        memcpy(guid, mbox->mbox_hdr.mailbox_guid, MAIL_GUID_128_SIZE);
        return 0;
 }
index f30b319315ffda0a18347a63bbbe95c1b7bab711..73bfc52206c8fbb1117c83b578a22b5b8a4e3484 100644 (file)
@@ -824,7 +824,11 @@ int mailbox_get_guid(struct mailbox *box, uint8_t guid[MAIL_GUID_128_SIZE])
                if (mailbox_open(box) < 0)
                        return -1;
        }
-       return box->v.get_guid(box, guid);
+       if (box->v.get_guid(box, guid) < 0)
+               return -1;
+
+       i_assert(!mail_guid_128_is_empty(guid));
+       return 0;
 }
 
 struct mailbox_sync_context *