]> 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)
committerGitLab <gitlab@git.dovecot.net>
Sat, 20 May 2017 18:22:23 +0000 (21:22 +0300)
Ignore them only if it's followed by an index reset.

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

index c2d7c14f8df4d78c0af41a009374f282b045623c..e13e1c005935a028e66bf7b4d7995c3ac714169a 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) {