dovecot: Fixed "file size unexpectedly shrinked" error in some c...

dovecot at dovecot.org dovecot at dovecot.org
Tue Oct 16 19:22:21 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/db6afac39fde
changeset: 6550:db6afac39fde
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Oct 16 19:22:17 2007 +0300
description:
Fixed "file size unexpectedly shrinked" error in some conditions.

diffstat:

1 file changed, 7 insertions(+), 1 deletion(-)
src/lib-storage/index/mbox/istream-raw-mbox.c |    8 +++++++-

diffs (32 lines):

diff -r bf5293708132 -r db6afac39fde src/lib-storage/index/mbox/istream-raw-mbox.c
--- a/src/lib-storage/index/mbox/istream-raw-mbox.c	Tue Oct 16 17:58:03 2007 +0300
+++ b/src/lib-storage/index/mbox/istream-raw-mbox.c	Tue Oct 16 19:22:17 2007 +0300
@@ -287,7 +287,9 @@ static ssize_t i_stream_raw_mbox_read(st
 		new_pos = from_start_pos;
 	} else {
 		/* leave out the beginnings of potential From-line + CR */
-		new_pos = i - (fromp - mbox_from) - 1;
+		new_pos = i - (fromp - mbox_from);
+		if (new_pos > 0)
+			new_pos--;
 	}
 
 	stream->buffer = buf;
@@ -481,6 +483,8 @@ uoff_t istream_raw_mbox_get_body_size(st
 	i_assert(rstream->body_offset != (uoff_t)-1);
 
 	if (rstream->mail_size != (uoff_t)-1) {
+		i_assert(rstream->mail_size >
+			 rstream->body_offset - rstream->hdr_offset);
 		return rstream->mail_size -
 			(rstream->body_offset - rstream->hdr_offset);
 	}
@@ -499,6 +503,8 @@ uoff_t istream_raw_mbox_get_body_size(st
 		i_stream_skip(stream, size);
 
 	i_assert(rstream->mail_size != (uoff_t)-1);
+	i_assert(rstream->mail_size >
+		 rstream->body_offset - rstream->hdr_offset);
 	return rstream->mail_size -
 		(rstream->body_offset - rstream->hdr_offset);
 }


More information about the dovecot-cvs mailing list