[dovecot-cvs] dovecot/src/lib-storage/index/mbox istream-raw-mbox.c, 1.36, 1.37 mbox-mail.c, 1.29, 1.30

cras at dovecot.org cras at dovecot.org
Wed Jan 11 22:45:06 EET 2006


Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv13232

Modified Files:
	istream-raw-mbox.c mbox-mail.c 
Log Message:
Handle unexpectedly breaking mboxes better without crashing.



Index: istream-raw-mbox.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/istream-raw-mbox.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- istream-raw-mbox.c	28 Oct 2005 11:49:34 -0000	1.36
+++ istream-raw-mbox.c	11 Jan 2006 20:45:03 -0000	1.37
@@ -397,6 +397,12 @@
 	if (rstream->hdr_offset == rstream->from_offset)
 		(void)_read(&rstream->istream);
 
+	if (rstream->corrupted) {
+		i_error("Unexpectedly lost From-line at "
+			"%"PRIuUOFF_T, rstream->from_offset);
+		return (uoff_t)-1;
+	}
+
 	return rstream->hdr_offset;
 }
 
@@ -416,8 +422,15 @@
 		i_stream_get_data(stream, &pos);
 		i_stream_skip(stream, pos);
 
-		if (_read(&rstream->istream) < 0)
+		if (_read(&rstream->istream) < 0) {
+			if (rstream->corrupted) {
+				i_error("Unexpectedly lost From-line at "
+					"%"PRIuUOFF_T, rstream->from_offset);
+			} else {
+				i_assert(rstream->body_offset != (uoff_t)-1);
+			}
 			break;
+		}
 	}
 
 	i_stream_seek(stream, offset);

Index: mbox-mail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-mail.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- mbox-mail.c	30 Dec 2005 13:05:50 -0000	1.29
+++ mbox-mail.c	11 Jan 2006 20:45:03 -0000	1.30
@@ -160,6 +160,8 @@
 	stream = mbox->mbox_stream;
 	hdr_offset = istream_raw_mbox_get_header_offset(stream);
 	body_offset = istream_raw_mbox_get_body_offset(stream);
+	if (body_offset == (uoff_t)-1)
+		return (uoff_t)-1;
 	body_size = istream_raw_mbox_get_body_size(stream, (uoff_t)-1);
 
 	data->physical_size = (body_offset - hdr_offset) + body_size;



More information about the dovecot-cvs mailing list