changeset 18680:1171265c3834

mbox: If we notice our internal state is wrong, avoid further corruption by returning error.
author Timo Sirainen <tss@iki.fi>
date Wed, 13 May 2015 19:26:45 +0300
parents b6ea460e7cc4
children 25dc311a5faa
files src/lib-storage/index/mbox/mbox-sync-rewrite.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-sync-rewrite.c	Wed May 13 19:24:55 2015 +0300
+++ b/src/lib-storage/index/mbox/mbox-sync-rewrite.c	Wed May 13 19:26:45 2015 +0300
@@ -429,6 +429,7 @@
 				" 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 @@
 		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;