diff options
| author | Marek Vasut <[email protected]> | 2026-01-28 20:40:40 +0100 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-02-06 09:29:48 -0600 |
| commit | 02ffe4a0c9d2885899648a5ffe22090e6c7ff9a5 (patch) | |
| tree | 242bc4e2523263250e58eccc88ac0cf617a43647 /cmd | |
| parent | 2e6b5185bd509d5c39bbdf900bf6ac9c12f2ed59 (diff) | |
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 <[email protected]>
Signed-off-by: Marek Vasut <[email protected]>
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/unzip.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/cmd/unzip.c b/cmd/unzip.c index e7a3f9808b2..da958f12803 100644 --- a/cmd/unzip.c +++ b/cmd/unzip.c @@ -53,8 +53,8 @@ static int do_gzwrite(struct cmd_tbl *cmdtp, int flag, unsigned char *addr; unsigned long length; unsigned long writebuf = 1<<20; - u64 startoffs = 0; - u64 szexpected = 0; + off_t startoffs = 0; + size_t szexpected = 0; if (argc < 5) return CMD_RET_USAGE; |
