]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: mail_transaction_log_view_set_all() - don't entirely ignore corrupted...
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 17 May 2017 10:31:09 +0000 (13:31 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 22 May 2017 12:12:12 +0000 (15:12 +0300)
Ignore them only if it's followed by an index reset.

src/lib-index/mail-transaction-log-view.c

index 4837b5eaea316b56b506eebeb3bb4037098bdb2e..b5581c8881c2c3d770642f7d276de88166ee60cc 100644 (file)
@@ -349,6 +349,7 @@ int mail_transaction_log_view_set_all(struct mail_transaction_log_view *view)
 {
        struct mail_transaction_log_file *file, *first;
        const char *reason;
+       int ret;
 
        /* make sure .log.2 file is opened */
        (void)mail_transaction_log_find_file(view->log, 1, FALSE, &file, &reason);
@@ -357,14 +358,22 @@ int mail_transaction_log_view_set_all(struct mail_transaction_log_view *view)
        i_assert(first != NULL);
 
        for (file = view->log->files; file != NULL; file = file->next) {
-               if (mail_transaction_log_file_map(file, file->hdr.hdr_size,
-                                                 (uoff_t)-1) < 0)
+               ret = mail_transaction_log_file_map(file, file->hdr.hdr_size,
+                                                   (uoff_t)-1);
+               if (ret < 0)
                        return -1;
-               if (file->hdr.prev_file_seq == 0) {
+               if (ret == 0) {
+                       /* corrupted */
+                       first = NULL;
+               } else if (file->hdr.prev_file_seq == 0) {
                        /* this file resets the index. skip the old ones. */
                        first = file;
                }
        }
+       if (first == NULL) {
+               /* index wasn't reset after corruption was found */
+               return -1;
+       }
 
        mail_transaction_log_view_unref_all(view);
        for (file = first; file != NULL; file = file->next) {