]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: istream-concat - Fix potential hang when reaching max buffer size
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 29 Oct 2024 09:25:32 +0000 (11:25 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 29 Oct 2024 14:40:50 +0000 (14:40 +0000)
src/lib/istream-concat.c

index 253edd6f6027eb999fe325238056b92cf63de006..a4860549ff77bc8b56088a7000c67778a87a0177 100644 (file)
@@ -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