]> git.ipfire.org Git - thirdparty/u-boot.git/commit
gunzip: Fix len parameter in function signature
authorMarek Vasut <marek.vasut+renesas@mailbox.org>
Wed, 28 Jan 2026 19:40:40 +0000 (20:40 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 6 Feb 2026 15:29:48 +0000 (09:29 -0600)
commit02ffe4a0c9d2885899648a5ffe22090e6c7ff9a5
tree242bc4e2523263250e58eccc88ac0cf617a43647
parent2e6b5185bd509d5c39bbdf900bf6ac9c12f2ed59
gunzip: Fix len parameter in function signature

The only call site of gzwrite() is cmd/unzip.c do_gzwrite(), where
the 'len' parameter passed to gzwrite(..., len, ...) function is of
type unsigned long. This usage is correct, the 'len' parameter is
an unsigned integer, and the gzwrite() function currently supports
input data 'len' of up to 4 GiB - 1 .

The function signature of gzwrite() function in both include/gzip.h
and lib/gunzip.c does however list 'len' as signed integer, which
is not correct, and ultimatelly limits the implementation to only
2 GiB input data 'len' .

Fix this, update gzwrite() function parameter 'len' data type to
size_t consistently in include/gzip.h and lib/gunzip.c .

Furthermore, update gzwrite() function 'szwritebuf' parameter in
lib/gunzip.c from 'unsigned long' to 'size_t' to be synchronized
with include/gzip.h . Rewrite the other parameters to size_t and
off_t and propagate the change too.

Since the gzwrite() function currently surely only supports input
data size of 4 GiB - 1, add input data size check. The limitation
comes from the current use of zlib z_stream .avail_in parameter,
to which the gzwrite() function sets the entire input data size,
and which is of unsigned int type, which cannot accept any number
beyond 4 GiB - 1. This limitation will be removed in future commit.

Reported-by: Yuya Hamamachi <yuya.hamamachi.sx@renesas.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
cmd/unzip.c
include/gzip.h
lib/gunzip.c