]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: fsck: Fix small log offsets to file's correct header size
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 20 May 2018 12:56:51 +0000 (15:56 +0300)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 7 Aug 2018 11:10:09 +0000 (14:10 +0300)
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)

src/lib-index/mail-index-fsck.c

index e4d5f4a8d32d3880d063d7193bfaaf59826eb027..f001eaff065bf02ef2f6015ef835adf9f6dc4402 100644 (file)
@@ -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;
 
@@ -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. */