From: Timo Sirainen Date: Wed, 13 May 2015 16:26:45 +0000 (+0300) Subject: mbox: If we notice our internal state is wrong, avoid further corruption by returning... X-Git-Tag: 2.2.17~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2b4fd3caed59dd24781d6905a3bc5675ff42b80;p=thirdparty%2Fdovecot%2Fcore.git mbox: If we notice our internal state is wrong, avoid further corruption by returning error. --- diff --git a/src/lib-storage/index/mbox/mbox-sync-rewrite.c b/src/lib-storage/index/mbox/mbox-sync-rewrite.c index 10b12a5d7f..222d45497c 100644 --- a/src/lib-storage/index/mbox/mbox-sync-rewrite.c +++ b/src/lib-storage/index/mbox/mbox-sync-rewrite.c @@ -429,6 +429,7 @@ static int mbox_sync_read_and_move(struct mbox_sync_context *sync_ctx, " bytes, now needs %"PRIuSIZE_T" bytes", seq, mails[idx].uid, mails[idx].uid_broken, (uoff_t)-mails[idx].space, need_space); + return -1; } } @@ -595,8 +596,10 @@ int mbox_sync_rewrite(struct mbox_sync_context *sync_ctx, mails[idx].from_offset += move_diff; } - i_assert(mails[idx].from_offset == start_offset); - i_assert(move_diff + (off_t)expunged_space >= 0); + if (ret == 0) { + i_assert(mails[idx].from_offset == start_offset); + i_assert(move_diff + (off_t)expunged_space >= 0); + } mbox_sync_file_updated(sync_ctx, FALSE); sync_ctx->prev_msg_uid = orig_prev_msg_uid;