@matheusbsbs / matheus-bagliano / commits / 1e80e04492
Fork 0

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 <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Johannes Schindelin committed Dec 22, 2005 at 18:55 UTC 1e80e0449248edb77b0fb9853f4a3404a599e207
1 file changed +2
sha1_file.c
+2
@@ -81,6 +81,8 @@ char * sha1_to_hex(const unsigned char *sha1)
81 *buf++ = hex[val >> 4];
82 *buf++ = hex[val & 0xf];
83 }
84 + *buf = '\0';
85 +
86 return buffer;
87 }
88