Re: [PATCH 03/10] builtin/tag.c: convert trivial snprintf calls to xsnprintf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 03/06/16 09:52, Jeff King wrote:
> On Fri, Jun 03, 2016 at 07:47:17AM +0000, Elia Pinto wrote:
> 
>>  builtin/tag.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/builtin/tag.c b/builtin/tag.c
>> index 50e4ae5..0345ca3 100644
>> --- a/builtin/tag.c
>> +++ b/builtin/tag.c
>> @@ -225,7 +225,7 @@ static void create_tag(const unsigned char *object, const char *tag,
>>  	if (type <= OBJ_NONE)
>>  	    die(_("bad object type."));
>>  
>> -	header_len = snprintf(header_buf, sizeof(header_buf),
>> +	header_len = xsnprintf(header_buf, sizeof(header_buf),
>>  			  "object %s\n"
>>  			  "type %s\n"
>>  			  "tag %s\n"
> 
> This is another of my "type 2" cases. I'd argue it should be using a
> heap buffer to handle tag and tagger names of arbitrary size.

Yep. As it stands, the code following this hunk:

        if (header_len > sizeof(header_buf) - 1)
                die(_("tag header too big."));

is now dead code, and the new error message is not as useful.

ATB,
Ramsay Jones

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]