Mercurial > dovecot > original-hg > dovecot-1.2
changeset 484:006202bcab99 HEAD
input buffer limit wasn't reset in error conditions.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 23 Oct 2002 20:02:42 +0300 |
parents | 990dae663bc3 |
children | 9f0263a945ba |
files | src/lib-index/mbox/mbox-rewrite.c |
diffstat | 1 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mbox/mbox-rewrite.c Wed Oct 23 16:19:56 2002 +0300 +++ b/src/lib-index/mbox/mbox-rewrite.c Wed Oct 23 20:02:42 2002 +0300 @@ -53,6 +53,7 @@ uoff_t end_offset) { uoff_t old_limit; + int failed; i_assert(inbuf->v_offset <= end_offset); @@ -61,16 +62,18 @@ if (o_buffer_send_ibuffer(outbuf, inbuf) < 0) { index_set_error(index, "Error rewriting mbox file %s: %s", index->mbox_path, strerror(outbuf->buf_errno)); + failed = TRUE; } else if (inbuf->v_offset < end_offset) { /* fsck should have noticed it.. */ index_set_error(index, "Error rewriting mbox file %s: " "Unexpected end of file", index->mbox_path); + failed = TRUE; } else { - return TRUE; + failed = FALSE; } i_buffer_set_read_limit(inbuf, old_limit); - return FALSE; + return !failed; } static int mbox_write_ximapbase(MboxRewriteContext *ctx) @@ -526,8 +529,11 @@ failed = TRUE; } - /* always end with a \n */ - (void)o_buffer_send(outbuf, "\n", 1); + if (!failed) { + /* always end with a \n */ + (void)o_buffer_send(outbuf, "\n", 1); + } + if (outbuf->closed) { errno = outbuf->buf_errno; mbox_set_syscall_error(index, "write()");