From: Timo Sirainen Date: Wed, 13 May 2015 16:24:55 +0000 (+0300) Subject: mbox: Fixed corruption in some usage patterns. X-Git-Tag: 2.2.17~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fcc2880f80385e29924aa926a1eefc5f0f41fa45;p=thirdparty%2Fdovecot%2Fcore.git mbox: Fixed corruption in some usage patterns. Something like: - first mail is being expunged - other mails are being rewritten and they get their space from the expunged mail - there's not enough space for the last mail to get space - we add more space - we'll now need to use up the space. We can't just decide to mark the mails dirty. --- diff --git a/src/lib-storage/index/mbox/mbox-sync.c b/src/lib-storage/index/mbox/mbox-sync.c index cf99716f10..c9f4883349 100644 --- a/src/lib-storage/index/mbox/mbox-sync.c +++ b/src/lib-storage/index/mbox/mbox-sync.c @@ -689,8 +689,10 @@ static int mbox_sync_handle_header(struct mbox_sync_mail_context *mail_ctx) } } else if (mail_ctx->need_rewrite) { mbox_sync_update_header(mail_ctx); - if (sync_ctx->delay_writes) { - /* mark it dirty and do it later */ + if (sync_ctx->delay_writes && sync_ctx->need_space_seq == 0) { + /* mark it dirty and do it later. we can't do this + if we're in the middle of rewriting acquiring more + space. */ mail_ctx->dirty = TRUE; return 0; }