[PATCH] gunzip: Fix len parameter in function signature

Marek Vasut marek.vasut at mailbox.org
Wed Jan 28 13:01:09 CET 2026


On 1/28/26 5:32 AM, Heinrich Schuchardt wrote:

Hello Heinrich,

>> diff --git a/include/gzip.h b/include/gzip.h
>> index 304002ffc42..5396e3ffec7 100644
>> --- a/include/gzip.h
>> +++ b/include/gzip.h
>> @@ -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
>> p */
>> -int gzwrite(unsigned char *src, int len, struct blk_desc *dev, ulong szwritebuf,
>> -	    ulong startoffs, ulong szexpected);
>> +int gzwrite(unsigned char *src, unsigned long len, struct blk_desc *dev,
>> +	    ulong szwritebuf, ulong startoffs, ulong szexpected);
> 
> Ulong and unsigned long are essentially the same but using both in one function signature looks weird.
> 
> I would prefer size_t for the size of objects in memory and off_t for file sizes and positions in files.
> 
> Please, consider adjusting startoffs and szexpected, too.

OK

>> /**
>>   * gzip()- Compress data into a buffer using the gzip algorithm
>> diff --git a/lib/gunzip.c b/lib/gunzip.c
>> index a05dcde9a75..040450c0e79 100644
>> --- a/lib/gunzip.c
>> +++ b/lib/gunzip.c
>> @@ -116,11 +116,8 @@ void gzwrite_progress_finish(int returnval,
>> 	}
>> }
>>
>> -int gzwrite(unsigned char *src, int len,
>> -	    struct blk_desc *dev,
>> -	    unsigned long szwritebuf,
>> -	    ulong startoffs,
>> -	    ulong szexpected)
>> +int gzwrite(unsigned char *src, unsigned long len, struct blk_desc *dev,
>> +	    ulong szwritebuf, ulong startoffs, ulong szexpected)
> 
> ditto
> 
>> {
>> 	int i, flags;
>> 	z_stream s;
>> @@ -133,6 +130,12 @@ int gzwrite(unsigned char *src, int len,
>> 	u32 payload_size;
>> 	int iteration = 0;
>>
>> +	if (len > 0xffffffff) {
>> +		printf("%s: input size over 4 GiB in size not supported\n",
>> +		       __func__);
> 
> Please, use log_err() for error output.
I believe log_*() primitives are frowned upon ? Tom ?


More information about the U-Boot mailing list