]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-ssl-iostream: ostream-openssl - Allocate at most IO_BLOCK_SIZE initial buffer
authorAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 11 Aug 2020 05:45:37 +0000 (08:45 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 11 Sep 2020 07:07:20 +0000 (07:07 +0000)
Otherwise we might attempt to allocate way too large buffers. This has not caused
issues yet, except with max_buffer_size=SIZE_T, which has been causing us to allocate
0-sized buffers.

src/lib-ssl-iostream/ostream-openssl.c

index ed80bf0acf68fdcaa57fc8c3f5a4d0a1a0a3255b..2e653c7e18d983c54dbf8bd163c6a5598bdf9d43 100644 (file)
@@ -57,7 +57,8 @@ o_stream_ssl_buffer(struct ssl_ostream *sstream, const struct const_iovec *iov,
        unsigned int i;
 
        if (sstream->buffer == NULL)
-               sstream->buffer = buffer_create_dynamic(default_pool, sstream->ostream.max_buffer_size);
+               sstream->buffer = buffer_create_dynamic(default_pool,
+                       I_MIN(IO_BLOCK_SIZE, sstream->ostream.max_buffer_size));
 
        skip_left = bytes_sent;
        for (i = 0; i < iov_count; i++) {