From: Timo Sirainen Date: Tue, 29 Oct 2024 09:25:32 +0000 (+0200) Subject: lib: istream-concat - Fix potential hang when reaching max buffer size X-Git-Tag: 2.4.0~1425 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2adea4a410011cc8e290da180d5fc25006b0d3fe;p=thirdparty%2Fdovecot%2Fcore.git lib: istream-concat - Fix potential hang when reaching max buffer size --- diff --git a/src/lib/istream-concat.c b/src/lib/istream-concat.c index 253edd6f60..a4860549ff 100644 --- a/src/lib/istream-concat.c +++ b/src/lib/istream-concat.c @@ -227,6 +227,13 @@ static ssize_t i_stream_concat_read(struct istream_private *stream) return -2; } stream->buffer = stream->w_buffer; + if (size < new_bytes_count) { + /* Everything couldn't be added to the concat-istream's + buffer. However, parent istream still contains data + in its buffer and it might not be receiving more. + Make sure the istream won't hang. */ + i_stream_set_input_pending(&stream->istream, TRUE); + } /* we'll copy all the new input to w_buffer. if we skip over prev_stream_left bytes, the next read will switch to