[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-save.c, 1.111, 1.112

tss at dovecot.org tss at dovecot.org
Thu Apr 26 21:30:22 EEST 2007


Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv15449

Modified Files:
	mbox-save.c 
Log Message:
If we synced the mbox while saving the message (happens only with quota
plugin loaded), we could have used a wrong append offset (calculated before
sync) which caused "Unexpectedly lost From-line" errors, and depending on
the sync either extra NUL lines or Content-Length header written over
existing mails (quite unlikely).



Index: mbox-save.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-save.c,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -d -r1.111 -r1.112
--- mbox-save.c	26 Apr 2007 18:26:52 -0000	1.111
+++ mbox-save.c	26 Apr 2007 18:30:19 -0000	1.112
@@ -309,12 +309,6 @@
 			   syncing. */
 			mbox_save_init_sync(t);
 		}
-
-		if (mbox_seek_to_end(ctx, &ctx->append_offset) < 0)
-			return -1;
-
-		ctx->output = o_stream_create_file(mbox->mbox_fd, default_pool,
-						   0, FALSE);
 	}
 
 	if (!ctx->synced && want_mail) {
@@ -324,6 +318,14 @@
 		mbox_save_init_sync(t);
 	}
 
+	/* the syncing above could have changed the append offset */
+	if (ctx->append_offset == (uoff_t)-1) {
+		if (mbox_seek_to_end(ctx, &ctx->append_offset) < 0)
+			return -1;
+
+		ctx->output = o_stream_create_file(mbox->mbox_fd, default_pool,
+						   0, FALSE);
+	}
 	return 0;
 }
 



More information about the dovecot-cvs mailing list