dovecot-1.1: mbox: Saving may have truncated the mail being saved.

dovecot at dovecot.org dovecot at dovecot.org
Mon Aug 4 17:16:40 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/8ab845d3c96d
changeset: 7803:8ab845d3c96d
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Aug 04 10:16:32 2008 -0400
description:
mbox: Saving may have truncated the mail being saved.
save_continue() must not return if there's still data to be saved and
index_mail_cache_parse_continue() may read more of it, so make sure after
calling that the save input is handled.

diffstat:

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

diffs (25 lines):

diff -r 1c010fadc9c9 -r 8ab845d3c96d src/lib-storage/index/mbox/mbox-save.c
--- a/src/lib-storage/index/mbox/mbox-save.c	Mon Aug 04 01:41:39 2008 +0300
+++ b/src/lib-storage/index/mbox/mbox-save.c	Mon Aug 04 10:16:32 2008 -0400
@@ -577,11 +577,9 @@ int mbox_save_continue(struct mail_save_
 		return mbox_save_body(ctx);
 	}
 
-	while ((ret = i_stream_read(ctx->input)) != -1) {
+	while ((ret = i_stream_read(ctx->input)) > 0) {
 		if (ctx->mail != NULL)
 			index_mail_cache_parse_continue(ctx->mail);
-		if (ret == 0)
-			return 0;
 
 		data = i_stream_get_data(ctx->input, &size);
 		for (i = 0; i < size; i++) {
@@ -608,6 +606,8 @@ int mbox_save_continue(struct mail_save_
 		ctx->last_char = data[size-1];
 		i_stream_skip(ctx->input, size);
 	}
+	if (ret == 0)
+		return 0;
 
 	if (ctx->last_char != '\n') {
 		if (o_stream_send(ctx->output, "\n", 1) < 0)


More information about the dovecot-cvs mailing list