dovecot-1.1: Don't crash if trying to open a non-file as mbox.

dovecot at dovecot.org dovecot at dovecot.org
Fri Mar 7 03:02:47 EET 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/33b90e21b634
changeset: 7365:33b90e21b634
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Mar 07 03:02:44 2008 +0200
description:
Don't crash if trying to open a non-file as mbox.

diffstat:

1 file changed, 6 insertions(+), 1 deletion(-)
src/lib-storage/index/mbox/mbox-sync.c |    7 ++++++-

diffs (24 lines):

diff -r 1b160b2cd080 -r 33b90e21b634 src/lib-storage/index/mbox/mbox-sync.c
--- a/src/lib-storage/index/mbox/mbox-sync.c	Fri Mar 07 02:46:57 2008 +0200
+++ b/src/lib-storage/index/mbox/mbox-sync.c	Fri Mar 07 03:02:44 2008 +0200
@@ -1228,6 +1228,11 @@ static int mbox_sync_handle_eof_updates(
 		mbox_set_syscall_error(sync_ctx->mbox, "i_stream_stat()");
 		return -1;
 	}
+	if (st->st_size < 0) {
+		/* Not a file - allow anyway */
+		return 0;
+	}
+
 	file_size = st->st_size;
 	if (file_size < sync_ctx->file_input->v_offset) {
 		mbox_sync_set_critical(sync_ctx,
@@ -1365,7 +1370,7 @@ static int mbox_sync_update_index_header
 
 	/* only reason not to have UID validity at this point is if the file
 	   is entirely empty. In that case just make up a new one if needed. */
-	i_assert(sync_ctx->base_uid_validity != 0 || st->st_size == 0);
+	i_assert(sync_ctx->base_uid_validity != 0 || st->st_size <= 0);
 
 	if (sync_ctx->base_uid_validity == 0) {
 		sync_ctx->base_uid_validity = sync_ctx->hdr->uid_validity != 0 ?


More information about the dovecot-cvs mailing list