]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mbox: Saving may have truncated the mail being saved.
authorTimo Sirainen <tss@iki.fi>
Mon, 4 Aug 2008 14:16:32 +0000 (10:16 -0400)
committerTimo Sirainen <tss@iki.fi>
Mon, 4 Aug 2008 14:16:32 +0000 (10:16 -0400)
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.

--HG--
branch : HEAD

src/lib-storage/index/mbox/mbox-save.c

index 7573cf2c1d08bd9286adf3729b7c868d2cb7cf51..a119e52dafe8d14792463938483bb7657a6963ed 100644 (file)
@@ -577,11 +577,9 @@ int mbox_save_continue(struct mail_save_context *_ctx)
                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_context *_ctx)
                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)