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

Re: [PATCH] pretty: avoid buffer overflow in format_person_part

From
Junio C Hamano <gitster@pobox.com>
Date
May 22, 2012, 20:53 UTC
Message-ID
<7vy5ok2aze.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20120522054508.GA10576@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 8 quoted lines
> A more ideal solution would be for mailmap to grow an
> interface that:
>
>   1. Takes a pointer and length combination, instead of
>      assuming a NUL-terminated string.
>
>   2. Returns a pointer to the mailmap's allocated string,
>      rather than copying it into the buffer.

I was looking at René's patch to refs codepath that converted some "we allocate because callee wants to have NUL-terminated strings" functions to take counted strings (or whatever we want to call it---perhaps "string slices"?), and it appears that we may benefit if more callers that do not have to own strings that comes to them used them instead of NUL-terminated strings as their interface. At some deep point near the leaf of the callchain, they may need to be converted in order to call external API (read: POSIX) that takes NUL-terminated strings, but internal callchain like the mailmap one, if done carefully, should let us avoid extra allocations.

Previous: Jeff King
Message 2 of 2 in “pretty: avoid buffer overflow in format_person_part”
  1. pretty: avoid buffer overflow in format_person_partJeff King, May 22, 2012
  2. Junio C HamanoMay 22, 2012

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.