]> git.ipfire.org Git - thirdparty/u-boot.git/commit
gunzip: Implement chunked decompression
authorMarek Vasut <marek.vasut+renesas@mailbox.org>
Thu, 19 Feb 2026 00:33:25 +0000 (01:33 +0100)
committerTom Rini <trini@konsulko.com>
Wed, 22 Apr 2026 19:51:41 +0000 (13:51 -0600)
commit58e523fedf48a304b54c4e42e46fd88d072f8751
tree2120e4b23382e09010151f146babb2133a7c04f2
parent70101c3217aec849d509040554ef0cf7c0f1ef56
gunzip: Implement chunked decompression

The current gzwrite() implementation is limited to 4 GiB compressed
input buffer size due to struct z_stream_s { uInt avail_in } member,
which is of type unsigned int. Current gzwrite() implementation sets
the entire input buffer size as avail_in and performs decompression
of the whole compressed input buffer in one round, which limits the
size of input buffer to 4 GiB.

Rework the decompression loop to use chunked approach, and decompress
the input buffer in up to 4 GiB - 1 kiB avail_in chunks, possibly in
multiple decompression rounds. This way, the compressed input buffer
size is limited by gzwrite() function 'len' parameter type, which is
unsigned long.

In case of sandbox build, include parsing of 'gzwrite_chunk'
environment variable, so the chunked approach can be thoroughly tested
with non default chunk size. For non-sandbox builds, the chunk size is
4 GiB - 1 kiB.

The gzwrite test case is extended to test various chunk sizes during
gzwrite decompression test.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
lib/gunzip.c
test/cmd/unzip.c