]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
i_stream_default_stat(): If we can't know the size, return -1 instead of assert crash.
authorTimo Sirainen <tss@iki.fi>
Tue, 27 Nov 2012 23:43:24 +0000 (01:43 +0200)
committerTimo Sirainen <tss@iki.fi>
Tue, 27 Nov 2012 23:43:24 +0000 (01:43 +0200)
This fixes a crash saving to mdbox when input stream's size wasn't known.

src/lib/istream.c

index 9179f607f2bd269affd12d95e3abc303d03b1bd0..0eb0ac6cd9cf4f29351c65cb4406983adb405377 100644 (file)
@@ -623,13 +623,13 @@ i_stream_default_stat(struct istream_private *stream, bool exact)
        if (stream->parent == NULL)
                return 0;
 
-       if (exact && !stream->stream_size_passthrough) {
-               i_panic("istream %s: stat() doesn't support getting exact size",
-                       i_stream_get_name(&stream->istream));
-       }
        if (i_stream_stat(stream->parent, exact, &st) < 0)
                return -1;
        stream->statbuf = *st;
+       if (exact && !stream->stream_size_passthrough) {
+               /* exact size is not known, even if parent returned something */
+               stream->statbuf.st_size = -1;
+       }
        return 0;
 }