dovecot-1.2: mbox: If mbox parsing notices unexpected corruption...

dovecot at dovecot.org dovecot at dovecot.org
Thu Dec 10 03:07:03 EET 2009


details:   http://hg.dovecot.org/dovecot-1.2/rev/fe1f31b4e21e
changeset: 9504:fe1f31b4e21e
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Dec 09 20:06:20 2009 -0500
description:
mbox: If mbox parsing notices unexpected corruption, don't assert-crash.

diffstat:

1 file changed, 8 insertions(+), 6 deletions(-)
src/lib-storage/index/mbox/mbox-sync.c |   14 ++++++++------

diffs (32 lines):

diff -r 8d4621094e54 -r fe1f31b4e21e src/lib-storage/index/mbox/mbox-sync.c
--- a/src/lib-storage/index/mbox/mbox-sync.c	Wed Dec 09 20:03:33 2009 -0500
+++ b/src/lib-storage/index/mbox/mbox-sync.c	Wed Dec 09 20:06:20 2009 -0500
@@ -147,6 +147,9 @@ mbox_sync_read_next_mail(struct mbox_syn
 	mbox_sync_parse_next_mail(sync_ctx->input, mail_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,
@@ -1144,13 +1147,12 @@ static int mbox_sync_loop(struct mbox_sy
 			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 */


More information about the dovecot-cvs mailing list