git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
May 12, 2008, 15:43 UTC
Message-ID
<482865A1.7040207@nrlssc.navy.mil>
In-Reply-To
<7vmymw3cst.fsf@gitster.siamese.dyndns.org>
Junio C Hamano wrote:
Show 17 quoted lines
> drafnel@gmail.com writes:
> 
>> From: Brandon Casey <casey@nrlssc.navy.mil>
>>
>> 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
Previous: Junio C HamanoNext: drafnel@gmail.com
Message 3 of 13 in “mktag.c: adjust verify_tag parameters”
  1. 1/5 mktag.c: adjust verify_tag parametersdrafnel@gmail.com, May 9, 2008
  2. Junio C HamanoMay 11, 2008
  3. Brandon CaseyMay 12, 2008
  4. 2/5 Make mktag a builtin.drafnel@gmail.com, May 9, 2008
  5. Junio C HamanoMay 11, 2008
  6. Junio C HamanoMay 11, 2008
  7. Brandon CaseyMay 12, 2008
  8. Johannes SchindelinMay 12, 2008
  9. Brandon CaseyMay 12, 2008
  10. Junio C HamanoMay 12, 2008
  11. 3/5 mktag.c: rename verify_tag to verify_tag_bufferdrafnel@gmail.com, May 9, 2008
  12. 4/5 mktag.c: consolidate tag functions by merging mktag.c into builtin-tag.cdrafnel@gmail.com, May 9, 2008
  13. 5/5 git-tag: call verify_tag_buffer to validate the generated tag objectdrafnel@gmail.com, May 9, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.