]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: istream-error - Set max_buffer_size
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 7 Dec 2020 11:07:35 +0000 (13:07 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Mon, 7 Dec 2020 12:30:36 +0000 (12:30 +0000)
Although nothing is actually read from the stream, some filter istreams
don't behave properly with max_buffer_size=0. Currently at least
istream-decrypt returns -2 for reads instead of -1.

Fixes:
Panic: file istream.c: line 320 (i_stream_read_memarea): assertion failed: (_stream->skip != _stream->pos)

src/lib/istream.c

index 06fd93e8ca28ec4aae44127c2412a5d0d1de83f4..09e15bf4ba5ae1cb9cf6eb4703b0460601f3d33b 100644 (file)
@@ -1224,6 +1224,10 @@ struct istream *i_stream_create_error(int stream_errno)
        stream->istream.seekable = TRUE;
        stream->istream.eof = TRUE;
        stream->istream.stream_errno = stream_errno;
+       /* Nothing can ever actually be read from this stream, but set a
+          reasonable max_buffer_size anyway since some filter istreams don't
+          behave properly otherwise. */
+       stream->max_buffer_size = IO_BLOCK_SIZE;
        i_stream_create(stream, NULL, -1, 0);
        i_stream_set_name(&stream->istream, "(error)");
        return &stream->istream;