]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Don't crash if trying to open a non-file as mbox.
authorTimo Sirainen <tss@iki.fi>
Fri, 7 Mar 2008 01:02:44 +0000 (03:02 +0200)
committerTimo Sirainen <tss@iki.fi>
Fri, 7 Mar 2008 01:02:44 +0000 (03:02 +0200)
--HG--
branch : HEAD

src/lib-storage/index/mbox/mbox-sync.c

index 89166b8618d1e4a37788cd28e33d44786618ec17..32d64ad6d4b2ac5d68364b081157727f952eace9 100644 (file)
@@ -1228,6 +1228,11 @@ static int mbox_sync_handle_eof_updates(struct mbox_sync_context *sync_ctx,
                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(struct mbox_sync_context *sync_ctx)
 
        /* 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 ?