[dovecot-cvs] dovecot/src/lib-storage/index/dbox dbox-save.c, 1.6, 1.7

cras at dovecot.org cras at dovecot.org
Wed Apr 12 19:51:40 EEST 2006


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

Modified Files:
	dbox-save.c 
Log Message:
ftruncate() the file after mail has been appended. We might have reused some
existing aborted mail in there.



Index: dbox-save.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-save.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- dbox-save.c	22 Feb 2006 16:02:27 -0000	1.6
+++ dbox-save.c	12 Apr 2006 16:51:38 -0000	1.7
@@ -249,6 +249,17 @@
 
 	ctx->finished = TRUE;
 	if (!ctx->failed) {
+		/* make sure the file ends here (we could have been
+		   overwriting some existing aborted mail) */
+		if (ftruncate(ctx->file->fd, ctx->file->output->offset) < 0) {
+			mail_storage_set_critical(STORAGE(ctx->mbox->storage),
+						  "ftruncate(%s) failed: %m",
+						  ctx->file->path);
+			ctx->failed = TRUE;
+		}
+	}
+
+	if (!ctx->failed) {
 		/* write mail size to header */
 		DEC2HEX(hdr.mail_size_hex,
 			ctx->file->output->offset - ctx->mail_offset);



More information about the dovecot-cvs mailing list