]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-compression: istream-lz4 - Add asserts to make sure parent buffer isn't full
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 16 Aug 2021 11:50:10 +0000 (14:50 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 16 Aug 2021 11:51:00 +0000 (14:51 +0300)
The parent buffer's max size would have to be tiny for these to happen.

src/lib-compression/istream-lz4.c

index 8638979a6e89ff899d7635a40b31faaa7f978bd9..ccfc924d4d982a80bfd7bf4c01d8a685f700e862 100644 (file)
@@ -52,6 +52,7 @@ static int i_stream_lz4_read_header(struct lz4_istream *zstream)
        buffer_append(zstream->chunk_buf, data, size);
        i_stream_skip(zstream->istream.parent, size);
        if (ret < 0) {
+               i_assert(ret != -2);
                if (zstream->istream.istream.stream_errno == 0) {
                        lz4_read_error(zstream, "missing header (not lz4 file?)");
                        zstream->istream.istream.stream_errno = EINVAL;
@@ -99,6 +100,7 @@ static int i_stream_lz4_read_chunk_header(struct lz4_istream *zstream)
        buffer_append(zstream->chunk_buf, data, size);
        i_stream_skip(stream->parent, size);
        if (ret < 0) {
+               i_assert(ret != -2);
                stream->istream.stream_errno = stream->parent->stream_errno;
                if (stream->istream.stream_errno == 0) {
                        stream->istream.eof = TRUE;