dovecot-2.0: mdbox purge: Fixes to handling corrupted mdbox files.

dovecot at dovecot.org dovecot at dovecot.org
Wed Mar 2 15:52:12 EET 2011


details:   http://hg.dovecot.org/dovecot-2.0/rev/989f3990b254
changeset: 12632:989f3990b254
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Mar 02 15:52:10 2011 +0200
description:
mdbox purge: Fixes to handling corrupted mdbox files.

diffstat:

 src/lib-storage/index/dbox-multi/mdbox-purge.c |  13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diffs (31 lines):

diff -r fe144ecec678 -r 989f3990b254 src/lib-storage/index/dbox-multi/mdbox-purge.c
--- a/src/lib-storage/index/dbox-multi/mdbox-purge.c	Wed Mar 02 15:51:28 2011 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-purge.c	Wed Mar 02 15:52:10 2011 +0200
@@ -222,7 +222,13 @@
 					  out_file_append->file->cur_path);
 		return -1;
 	}
-	i_assert(ret == (off_t)msg_size);
+	if (ret != (off_t)msg_size) {
+		i_assert(ret < (off_t)msg_size);
+		i_assert(i_stream_is_eof(file->input));
+
+		dbox_file_set_corrupted(file, "truncated message at EOF");
+		return 0;
+	}
 
 	/* copy metadata */
 	if ((ret = mdbox_file_metadata_copy(file, output)) <= 0)
@@ -366,10 +372,9 @@
 		} else {
 			/* non-expunged message. write it to output file. */
 			i_stream_seek(file->input, offset);
-			if (mdbox_purge_save_msg(ctx, file, &msgs[i]) < 0) {
-				ret = -1;
+			ret = mdbox_purge_save_msg(ctx, file, &msgs[i]);
+			if (ret <= 0)
 				break;
-			}
 			array_append(&copied_map_uids, &msgs[i].map_uid, 1);
 		}
 		offset = file->input->v_offset;


More information about the dovecot-cvs mailing list