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

Re: [PATCH] sha1_to_hex: properly terminate the SHA1

From
Junio C Hamano <junkio@cox.net>
Date
Dec 22, 2005, 20:51 UTC
Message-ID
<7voe38j1n4.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.63.0512221854550.20025@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 7 quoted lines
> sha1_to_hex() returns a pointer to a static buffer. Some of its users
> modify that buffer by appending a newline character. Other users rely
> on the fact that you can call
>
> 	printf("%s", sha1_to_hex(sha1));
>
> Just to be on the safe side, terminate the SHA1 in sha1_to_hex().
Good catch, thanks.  The worst one is:
diff.c:727:		memcpy(one_sha1, sha1_to_hex(one->sha1), 41);
Previous: Johannes Schindelin
Message 2 of 2 in “sha1_to_hex: properly terminate the SHA1”
  1. sha1_to_hex: properly terminate the SHA1Johannes Schindelin, Dec 22, 2005
  2. Junio C HamanoDec 22, 2005

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.