[dovecot-cvs]
dovecot/src/lib-index mail-transaction-log-view.c, 1.8,
1.9 mail-transaction-log.c, 1.14, 1.15
cras at procontrol.fi
cras at procontrol.fi
Sun May 2 15:57:32 EEST 2004
Update of /home/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv764/lib-index
Modified Files:
mail-transaction-log-view.c mail-transaction-log.c
Log Message:
Don't crash in assert() with corrupted index file.
Index: mail-transaction-log-view.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-transaction-log-view.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- mail-transaction-log-view.c 1 May 2004 16:08:15 -0000 1.8
+++ mail-transaction-log-view.c 2 May 2004 12:57:29 -0000 1.9
@@ -84,8 +84,6 @@
i_assert(view->broken);
i_assert(min_file_seq <= max_file_seq);
- i_assert(min_file_offset >= sizeof(struct mail_transaction_log_header));
- i_assert(max_file_offset >= sizeof(struct mail_transaction_log_header));
if (view->log == NULL)
return -1;
@@ -118,6 +116,14 @@
max_file_offset = min_file_offset;
}
}
+
+ /* check these later than others as index file may have corrupted
+ log_file_offset. we should have recreated the log file and
+ skipped min_file_seq file above.. max_file_offset can be broken
+ only if min_file_seq = max_file_seq. */
+ i_assert(min_file_offset >= sizeof(struct mail_transaction_log_header));
+ i_assert(max_file_offset >= sizeof(struct mail_transaction_log_header));
+
end_offset = min_file_seq == max_file_seq ?
max_file_offset : (uoff_t)-1;
ret = mail_transaction_log_file_map(file, min_file_offset, end_offset);
Index: mail-transaction-log.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-transaction-log.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- mail-transaction-log.c 1 May 2004 16:08:15 -0000 1.14
+++ mail-transaction-log.c 2 May 2004 12:57:29 -0000 1.15
@@ -62,10 +62,11 @@
}
#define INDEX_HAS_MISSING_LOGS(index, file) \
- ((file)->hdr.file_seq != (index)->hdr->log_file_seq && \
- ((file)->hdr.prev_file_seq != (index)->hdr->log_file_seq || \
- (file)->hdr.prev_file_offset != (index)->hdr->log_file_offset))
-
+ !(((file)->hdr.file_seq == (index)->hdr->log_file_seq && \
+ (index)->hdr->log_file_offset >= \
+ sizeof(struct mail_transaction_log_header)) || \
+ ((file)->hdr.prev_file_seq == (index)->hdr->log_file_seq && \
+ (file)->hdr.prev_file_offset == (index)->hdr->log_file_offset))
static int mail_transaction_log_check_file_seq(struct mail_transaction_log *log)
{
More information about the dovecot-cvs
mailing list