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 /include | |
| 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 'include')
| -rw-r--r-- | include/gzip.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/include/gzip.h b/include/gzip.h index 304002ffc42..fe8e21dc2a9 100644 --- a/include/gzip.h +++ b/include/gzip.h @@ -58,11 +58,11 @@ int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp, * gzwrite_progress_finish called at end of loop to * indicate success (retcode=0) or failure */ -void gzwrite_progress_init(ulong expected_size); +void gzwrite_progress_init(size_t expected_size); -void gzwrite_progress(int iteration, ulong bytes_written, ulong total_bytes); +void gzwrite_progress(int iteration, ulong bytes_written, size_t total_bytes); -void gzwrite_progress_finish(int retcode, ulong totalwritten, ulong totalsize, +void gzwrite_progress_finish(int retcode, ulong totalwritten, size_t totalsize, u32 expected_crc, u32 calculated_crc); /** @@ -77,8 +77,8 @@ void gzwrite_progress_finish(int retcode, ulong totalwritten, ulong totalsize, * for files under 4GiB * Return: 0 if OK, -1 on error */ -int gzwrite(unsigned char *src, int len, struct blk_desc *dev, ulong szwritebuf, - ulong startoffs, ulong szexpected); +int gzwrite(unsigned char *src, size_t len, struct blk_desc *dev, + size_t szwritebuf, off_t startoffs, size_t szexpected); /** * gzip()- Compress data into a buffer using the gzip algorithm |
