From: Timo Sirainen Date: Mon, 15 Feb 2010 05:08:40 +0000 (+0200) Subject: mbox: Make sure we have valid mailbox GUID when returning it. X-Git-Tag: 2.0.beta3~65 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0cb1eb9a12488be403e4179877c31729efaa3c2f;p=thirdparty%2Fdovecot%2Fcore.git mbox: Make sure we have valid mailbox GUID when returning it. --HG-- branch : HEAD --- diff --git a/src/lib-storage/index/mbox/mbox-storage.c b/src/lib-storage/index/mbox/mbox-storage.c index 627a7cc291..7730bd9bb2 100644 --- a/src/lib-storage/index/mbox/mbox-storage.c +++ b/src/lib-storage/index/mbox/mbox-storage.c @@ -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; } diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index f30b319315..73bfc52206 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -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 *