[dovecot-cvs]
dovecot/src/lib-storage/index/mbox mbox-sync.c, 1.103, 1.104
cras at dovecot.org
cras at dovecot.org
Wed Oct 13 23:21:23 EEST 2004
Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv12686/lib-storage/index/mbox
Modified Files:
mbox-sync.c
Log Message:
Added asserts
Index: mbox-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync.c,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -d -r1.103 -r1.104
--- mbox-sync.c 11 Oct 2004 14:29:51 -0000 1.103
+++ mbox-sync.c 13 Oct 2004 20:21:21 -0000 1.104
@@ -932,7 +932,7 @@
static int mbox_sync_handle_eof_updates(struct mbox_sync_context *sync_ctx,
struct mbox_sync_mail_context *mail_ctx)
{
- uoff_t offset, padding, trailer_size, old_file_size;
+ uoff_t file_size, offset, padding, trailer_size, old_file_size;
if (!istream_raw_mbox_is_eof(sync_ctx->input)) {
i_assert(sync_ctx->need_space_seq == 0);
@@ -940,8 +940,9 @@
return 0;
}
- trailer_size = i_stream_get_size(sync_ctx->file_input) -
- sync_ctx->file_input->v_offset;
+ file_size = i_stream_get_size(sync_ctx->file_input);
+ i_assert(file_size >= sync_ctx->file_input->v_offset);
+ trailer_size = file_size - sync_ctx->file_input->v_offset;
if (sync_ctx->need_space_seq != 0) {
i_assert(sync_ctx->space_diff < 0);
@@ -983,8 +984,9 @@
if (sync_ctx->expunged_space > 0) {
/* copy trailer, then truncate the file */
- offset = i_stream_get_size(sync_ctx->file_input) -
- sync_ctx->expunged_space - trailer_size;
+ file_size = i_stream_get_size(sync_ctx->file_input);
+ i_assert(file_size >= sync_ctx->expunged_space + trailer_size);
+ offset = file_size - sync_ctx->expunged_space - trailer_size;
if (mbox_move(sync_ctx, offset,
offset + sync_ctx->expunged_space,
More information about the dovecot-cvs
mailing list