From: Timo Sirainen Date: Tue, 19 Feb 2019 08:17:45 +0000 (+0200) Subject: lib: istream-seekable - Change stream to be blocking=TRUE after reaching EOF X-Git-Tag: 2.3.9~818 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1372692923ad0cef8e0671be9664644ddf61ba75;p=thirdparty%2Fdovecot%2Fcore.git lib: istream-seekable - Change stream to be blocking=TRUE after reaching EOF After EOF is reached, the stream is now fully read into file or memory. read()s can no longer return 0, so blocking=TRUE can be used. Some callers were reusing the seekable stream in places that required blocking=TRUE. Fixes at least with imapsieve vnd.dovecot report extension: Panic: file ostream.c: line 427 (o_stream_nsend_istream): assertion failed: (instream->blocking) --- diff --git a/src/lib/istream-seekable.c b/src/lib/istream-seekable.c index 875bba667f..67ff65620b 100644 --- a/src/lib/istream-seekable.c +++ b/src/lib/istream-seekable.c @@ -164,6 +164,10 @@ static ssize_t read_more(struct seekable_istream *sstream) /* last one, EOF */ sstream->size = sstream->istream.istream.v_offset; sstream->istream.istream.eof = TRUE; + /* Now that EOF is reached, the stream can't return 0 + anymore. Callers can now use this stream in places + that assert that blocking==TRUE. */ + sstream->istream.istream.blocking = TRUE; unref_streams(sstream); return -1; }