From: Timo Sirainen Date: Tue, 22 Nov 2016 10:03:01 +0000 (+0200) Subject: lib-index: Handle invalid headers as "corruption", not "temporary error" X-Git-Tag: 2.2.27~76 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=323d035fb645850fd12f67f1dbf31e1d741925f2;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Handle invalid headers as "corruption", not "temporary error" This is especially required for "Header's corrupted flag is set" error, which won't get fixed otherwise. It's a bit more questionable if we should treat major version or CPU architecture change as corruption, but it's possible those only exist because of corruption. It's also very unlikely that either is really happening. Ideally there would be a hash that verifies whether the header is corrupted or not. --- diff --git a/src/lib-index/mail-index-map-hdr.c b/src/lib-index/mail-index-map-hdr.c index 8a59534a2c..b1d232d996 100644 --- a/src/lib-index/mail-index-map-hdr.c +++ b/src/lib-index/mail-index-map-hdr.c @@ -238,7 +238,7 @@ int mail_index_map_check_header(struct mail_index_map *map, const struct mail_index_header *hdr = &map->hdr; if (!mail_index_check_header_compat(index, hdr, (uoff_t)-1, error_r)) - return -1; + return 0; /* following some extra checks that only take a bit of CPU */ if (hdr->record_size < sizeof(struct mail_index_record)) { diff --git a/src/lib-index/mail-index-map-read.c b/src/lib-index/mail-index-map-read.c index aa905ed727..b17a740433 100644 --- a/src/lib-index/mail-index-map-read.c +++ b/src/lib-index/mail-index-map-read.c @@ -76,7 +76,7 @@ static int mail_index_mmap(struct mail_index_map *map, uoff_t file_size) /* Can't use this file */ mail_index_set_error(index, "Corrupted index file %s: %s", index->filepath, error); - return -1; + return 0; } rec_map->mmap_used_size = hdr->header_size + @@ -159,7 +159,7 @@ mail_index_try_read_map(struct mail_index_map *map, /* Can't use this file */ mail_index_set_error(index, "Corrupted index file %s: %s", index->filepath, error); - return -1; + return 0; } initial_buf_pos = pos;