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

Re: [PATCH] sha1_name: use strlcpy() to copy strings

From
René Scharfe <l.s.r@web.de>
Date
Feb 22, 2015, 22:33 UTC
Message-ID
<54EA592C.6040701@web.de>
In-Reply-To
<xmqqsidxvhrk.fsf@gitster.dls.corp.google.com>
Am 22.02.2015 um 21:00 schrieb Junio C Hamano:
Show 8 quoted lines
> René Scharfe <l.s.r@web.de> writes:
>
>> Use strlcpy() instead of calling strncpy() and then setting the last
>> byte of the target buffer to NUL explicitly.  This shortens and
>> simplifies the code a bit.
>
> Thanks.  It makes me wonder if the longer term direction should be
> not to use a bound buffer for oc->path, though.

That's a good idea in general, but a bit more involved since we'd need to introduce a cleanup function that releases the memory allocated by the new version of get_sha1_with_context() first and call it from the appropriate places.

Would that be a good micro-project for GSoC or is it too simple?
René
Previous: Junio C HamanoNext: Jeff King
Message 3 of 4 in “sha1_name: use strlcpy() to copy strings”
  1. sha1_name: use strlcpy() to copy stringsRené Scharfe, Feb 21, 2015
  2. Junio C HamanoFeb 22, 2015
  3. René ScharfeFeb 22, 2015
  4. Jeff KingFeb 23, 2015

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.