From: Timo Sirainen Date: Tue, 27 Nov 2012 23:43:24 +0000 (+0200) Subject: i_stream_default_stat(): If we can't know the size, return -1 instead of assert crash. X-Git-Tag: 2.2.beta1~83 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9db5ade1c16c7f67c51004f28c28ea335755d3f0;p=thirdparty%2Fdovecot%2Fcore.git i_stream_default_stat(): If we can't know the size, return -1 instead of assert crash. This fixes a crash saving to mdbox when input stream's size wasn't known. --- diff --git a/src/lib/istream.c b/src/lib/istream.c index 9179f607f2..0eb0ac6cd9 100644 --- a/src/lib/istream.c +++ b/src/lib/istream.c @@ -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; }