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.