]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Handle invalid headers as "corruption", not "temporary error"
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 22 Nov 2016 10:03:01 +0000 (12:03 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 23 Nov 2016 11:37:32 +0000 (13:37 +0200)
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.

src/lib-index/mail-index-map-hdr.c
src/lib-index/mail-index-map-read.c

index 8a59534a2c19f19b5a75a61b40686f945ff4b40d..b1d232d9961216000478e7baa85217d2117afb2f 100644 (file)
@@ -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)) {
index aa905ed72771ceac724922b4bfe24aeed4121a33..b17a74043373b70bf66dec6a4a5a3f52a6717a36 100644 (file)
@@ -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;