Skip to content

Commit

Permalink
lib-index: fsck: Fix small log offsets to file's correct header size
Browse files Browse the repository at this point in the history
Use the file's actual current header size, not
MAIL_TRANSACTION_LOG_HEADER_MIN_SIZE, which is nowadays smaller. This
resulted in unnecessary errors like:

Corrupted transaction log file ...: Invalid min_file_offset: ..., min_file_offset (24) < hdr_size (40)
  • Loading branch information
sirainen committed May 20, 2018
1 parent 308048a commit f04adc2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/lib-index/mail-index-fsck.c
Expand Up @@ -29,6 +29,7 @@ static void
mail_index_fsck_log_pos(struct mail_index *index, struct mail_index_map *map,
struct mail_index_header *hdr)
{
unsigned int hdr_size = index->log->head->hdr.hdr_size;
uint32_t file_seq;
uoff_t file_offset;

Expand All @@ -42,14 +43,14 @@ mail_index_fsck_log_pos(struct mail_index *index, struct mail_index_map *map,
offsets are valid. */
if (hdr->log_file_head_offset > file_offset)
hdr->log_file_head_offset = file_offset;
else if (hdr->log_file_head_offset < MAIL_TRANSACTION_LOG_HEADER_MIN_SIZE)
hdr->log_file_head_offset = MAIL_TRANSACTION_LOG_HEADER_MIN_SIZE;
else if (hdr->log_file_head_offset < hdr_size)
hdr->log_file_head_offset = hdr_size;

if (hdr->log_file_tail_offset > hdr->log_file_head_offset)
hdr->log_file_tail_offset = hdr->log_file_head_offset;
else if (hdr->log_file_tail_offset != 0 &&
hdr->log_file_tail_offset < MAIL_TRANSACTION_LOG_HEADER_MIN_SIZE)
hdr->log_file_tail_offset = MAIL_TRANSACTION_LOG_HEADER_MIN_SIZE;
hdr->log_file_tail_offset < hdr_size)
hdr->log_file_tail_offset = hdr_size;
} else {
/* index's log_file_seq is newer than exists. move it to
end of the current log head. */
Expand Down

0 comments on commit f04adc2

Please sign in to comment.