]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mbox: If mbox parsing notices unexpected corruption, don't assert-crash.
authorTimo Sirainen <tss@iki.fi>
Thu, 10 Dec 2009 01:06:20 +0000 (20:06 -0500)
committerTimo Sirainen <tss@iki.fi>
Thu, 10 Dec 2009 01:06:20 +0000 (20:06 -0500)
--HG--
branch : HEAD

src/lib-storage/index/mbox/mbox-sync.c

index 65651cbbbf5128ffa512994b468fad96fe1e4d54..467ae408f53fa8138f9428f12fb41aee11c4c024 100644 (file)
@@ -150,6 +150,9 @@ mbox_sync_read_next_mail(struct mbox_sync_context *sync_ctx,
        i_assert(sync_ctx->input->v_offset != mail_ctx->mail.from_offset ||
                 sync_ctx->input->eof);
 
+       if (istream_raw_mbox_is_corrupted(sync_ctx->input))
+               return -1;
+
        mail_ctx->mail.body_size =
                istream_raw_mbox_get_body_size(sync_ctx->input,
                                               mail_ctx->content_length);
@@ -1167,13 +1170,12 @@ static int mbox_sync_loop(struct mbox_sync_context *sync_ctx,
                        ret = mbox_sync_partial_seek_next(sync_ctx, uid + 1,
                                                          &partial,
                                                          &skipped_mails);
-                       if (ret <= 0) {
-                               if (ret < 0)
-                                       return -1;
+                       if (ret <= 0)
                                break;
-                       }
                }
        }
+       if (ret < 0)
+               return -1;
 
        if (istream_raw_mbox_is_eof(sync_ctx->input)) {
                /* rest of the messages in index don't exist -> expunge them */