]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fs-compress: Limit minimum buffer size to 1k
authorAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 18 Sep 2023 10:38:50 +0000 (13:38 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 27 Nov 2023 08:37:44 +0000 (08:37 +0000)
Otherwise we might not get enough data to decompress
the stream.

src/plugins/fs-compress/fs-compress.c

index 4d82f075a6edf5830a17af60bb17b1f814f6f7b1..83afc87e516659d63bc288a09055c71ca139538f 100644 (file)
@@ -10,6 +10,8 @@
 #include "compression.h"
 #include "fs-api-private.h"
 
+#define FS_COMPRESS_ISTREAM_MIN_BUFFER_SIZE 1024
+
 struct compress_fs {
        struct fs fs;
        const struct compression_handler *compress_handler;
@@ -173,7 +175,8 @@ fs_compress_read_stream(struct fs_file *_file, size_t max_buffer_size)
                return file->input;
        }
 
-       input = fs_read_stream(file->super_read, max_buffer_size);
+       input = fs_read_stream(file->super_read,
+               I_MAX(FS_COMPRESS_ISTREAM_MIN_BUFFER_SIZE, max_buffer_size));
        if (file->fs->try_plain)
                flags |= ISTREAM_DECOMPRESS_FLAG_TRY;
        file->input = i_stream_create_decompress(input, flags);