Re: [PATCH 1/5] mktag.c: adjust verify_tag parameters

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

 



Junio C Hamano wrote:
> drafnel@xxxxxxxxx writes:
> 
>> From: Brandon Casey <casey@xxxxxxxxxxxxxxx>
>>
>> The size parameter should be a size_t since it is a string length.
> 
> Correct.
> 
>> There is no reason that the buffer argument should not be constant except
>> for the nul termination that is performed in the first few lines of this
>> function. This is not necessary, since a valid c string must always be
>> nul terminated and we can check whether we have exceeded the caller's
>> size parameter at the end of parsing the buffer.
> 
> Wait a minute.  The point of passing a stringlet as a tuple of <pointer to
> the beginning, length> is that you may not have a valid C string to begin
> with, isn't it?

I thought it was just to limit the scope of parsing.

Other functions that deal with non-nul-terminated memory segments (like memchr)
do not use char*, they instead use void*.

If we want to handle non-nul-terminated memory segments here, we should
probably allocate a new string to copy the memory segment into so we can
ensure it is nul-terminated. Otherwise we can't use any of the str*()
functions safely.

-brandon
--
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]

  Powered by Linux