From: Timo Sirainen Date: Thu, 14 Oct 2010 15:53:04 +0000 (+0100) Subject: lib-storage: If mailbox deletion failed, we crashed while trying to write undelete... X-Git-Tag: 2.0.6~72 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=038cb2779978bd38fb2128b4d83e9302c0531d78;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: If mailbox deletion failed, we crashed while trying to write undelete record to index. --- diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index eb24af804e..ae4f7a2b31 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -669,8 +669,10 @@ int mailbox_update(struct mailbox *box, const struct mailbox_update *update) int mailbox_mark_index_deleted(struct mailbox *box, bool del) { - enum mail_index_transaction_flags trans_flags = 0; struct mail_index_transaction *trans; + enum mail_index_transaction_flags trans_flags = 0; + enum mailbox_flags old_flag; + int ret; if (box->marked_deleted && del) { /* we already marked it deleted. this allows plugins to @@ -678,6 +680,13 @@ int mailbox_mark_index_deleted(struct mailbox *box, bool del) return 0; } + old_flag = box->flags & MAILBOX_FLAG_OPEN_DELETED; + box->flags |= MAILBOX_FLAG_OPEN_DELETED; + ret = mailbox_open(box); + box->flags = (box->flags & ~MAILBOX_FLAG_OPEN_DELETED) | old_flag; + if (ret < 0) + return -1; + trans_flags = del ? 0 : MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL; trans = mail_index_transaction_begin(box->view, trans_flags); if (del)