From: Johannes Schindelin Date: Thu, 22 Dec 2005 17:55:59 +0000 (+0100) Subject: sha1_to_hex: properly terminate the SHA1 X-Git-Tag: v1.0.3^2 X-Git-Url: https://git.octo.it/?p=git.git;a=commitdiff_plain;h=1e80e0449248edb77b0fb9853f4a3404a599e207 sha1_to_hex: properly terminate the SHA1 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(). Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- diff --git a/sha1_file.c b/sha1_file.c index 60114735..d451a94e 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -81,6 +81,8 @@ char * sha1_to_hex(const unsigned char *sha1) *buf++ = hex[val >> 4]; *buf++ = hex[val & 0xf]; } + *buf = '\0'; + return buffer; }