summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2005-12-22 17:55:59 (GMT)
committerJunio C Hamano <junkio@cox.net>2005-12-22 20:52:37 (GMT)
commit1e80e0449248edb77b0fb9853f4a3404a599e207 (patch)
tree6796de66f2dfb8ba71ae50ac4c5cc2e1c58438ea /sha1_file.c
parenta14c225661fa2fc271d9e0fbf262e369dc7254fc (diff)
downloadgit-1e80e0449248edb77b0fb9853f4a3404a599e207.zip
git-1e80e0449248edb77b0fb9853f4a3404a599e207.tar.gz
git-1e80e0449248edb77b0fb9853f4a3404a599e207.tar.bz2
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>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 6011473..d451a94 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;
}