[dovecot-cvs] dovecot/src/lib-index/mbox mbox-rewrite.c,1.29,1.30
cras at procontrol.fi
cras at procontrol.fi
Wed Oct 23 21:02:44 EEST 2002
Update of /home/cvs/dovecot/src/lib-index/mbox
In directory danu:/tmp/cvs-serv19820
Modified Files:
mbox-rewrite.c
Log Message:
input buffer limit wasn't reset in error conditions.
Index: mbox-rewrite.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mbox/mbox-rewrite.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- mbox-rewrite.c 19 Oct 2002 16:40:17 -0000 1.29
+++ mbox-rewrite.c 23 Oct 2002 17:02:42 -0000 1.30
@@ -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()");
More information about the dovecot-cvs
mailing list