Mercurial > dovecot > original-hg > dovecot-1.2
changeset 2955:d5ee1bbd15f0 HEAD
Fixed mbox corruption in certain situations. Added more asserts to catch
similiar problems if there still happens to be any.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 07 Dec 2004 22:26:00 +0200 |
parents | 9dc7a7b06781 |
children | cd257e96a370 |
files | src/lib-storage/index/mbox/mbox-sync-parse.c src/lib-storage/index/mbox/mbox-sync-rewrite.c src/lib-storage/index/mbox/mbox-sync.c |
diffstat | 3 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-sync-parse.c Tue Dec 07 05:59:20 2004 +0200 +++ b/src/lib-storage/index/mbox/mbox-sync-parse.c Tue Dec 07 22:26:00 2004 +0200 @@ -58,6 +58,7 @@ } if ((ssize_t)space > ctx->mail.space) { + i_assert(space != 0); ctx->mail.offset = hdr->full_value_offset + i; ctx->mail.space = space; }
--- a/src/lib-storage/index/mbox/mbox-sync-rewrite.c Tue Dec 07 05:59:20 2004 +0200 +++ b/src/lib-storage/index/mbox/mbox-sync-rewrite.c Tue Dec 07 22:26:00 2004 +0200 @@ -118,8 +118,10 @@ ctx->header_first_change = pos; ctx->header_last_change = (size_t)-1; - ctx->mail.offset = ctx->hdr_offset + start_pos; ctx->mail.space = (pos - start_pos) + size; + ctx->mail.offset = ctx->hdr_offset; + if (ctx->mail.space > 0) + ctx->mail.offset += start_pos; } static void mbox_sync_header_remove_space(struct mbox_sync_mail_context *ctx, @@ -174,7 +176,9 @@ if (ctx->mail.space < (off_t)(data_size - last_line_pos)) { ctx->mail.space = data_size - last_line_pos; - ctx->mail.offset = ctx->hdr_offset + last_line_pos; + ctx->mail.offset = ctx->hdr_offset; + if (ctx->mail.space > 0) + ctx->mail.offset += last_line_pos; } } @@ -487,6 +491,7 @@ } i_assert(move_diff >= 0 || idx == first_nonexpunged_idx); + i_assert(next_end_offset <= end_offset); end_offset = next_end_offset; mails[idx].from_offset += move_diff;
--- a/src/lib-storage/index/mbox/mbox-sync.c Tue Dec 07 05:59:20 2004 +0200 +++ b/src/lib-storage/index/mbox/mbox-sync.c Tue Dec 07 22:26:00 2004 +0200 @@ -609,6 +609,8 @@ uoff_t end_offset, move_diff, extra_space, needed_space; uint32_t last_seq; + i_assert(mail_ctx->mail.uid == 0 || mail_ctx->mail.space > 0 || + mail_ctx->mail.offset == mail_ctx->hdr_offset); buffer_append(sync_ctx->mails, &mail_ctx->mail, sizeof(mail_ctx->mail)); sync_ctx->space_diff += mail_ctx->mail.space;