dovecot-2.2: fs-metawrap: If written file unexpectedly shrinks, ...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jun 15 11:54:20 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/bd1dabfcfae3
changeset: 18857:bd1dabfcfae3
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Jun 15 14:51:46 2015 +0300
description:
fs-metawrap: If written file unexpectedly shrinks, return error instead of assert-crash.
This shouldn't be happening, but we can't fully control it so an error is
better.

diffstat:

 src/lib-fs/fs-metawrap.c |  9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diffs (19 lines):

diff -r db8877fdd39f -r bd1dabfcfae3 src/lib-fs/fs-metawrap.c
--- a/src/lib-fs/fs-metawrap.c	Mon Jun 15 14:49:46 2015 +0300
+++ b/src/lib-fs/fs-metawrap.c	Mon Jun 15 14:51:46 2015 +0300
@@ -457,7 +457,14 @@
 		/* fs_stat() after a write. we can do this quickly. */
 		if (fs_stat(file->super, st_r) < 0)
 			return -1;
-		i_assert((uoff_t)st_r->st_size >= file->metadata_write_size);
+		if ((uoff_t)st_r->st_size < file->metadata_write_size) {
+			fs_set_error(_file->fs,
+				"Just-written %s shrank unexpectedly "
+				"(%"PRIuUOFF_T" < %"PRIuUOFF_T")",
+				fs_file_path(_file), st_r->st_size,
+				file->metadata_write_size);
+			return -1;
+		}
 		st_r->st_size -= file->metadata_write_size;
 		return 0;
 	}


More information about the dovecot-cvs mailing list