[sheepdog] [PATCH 1/2] sheep: fix sha1_to_hex

Yunkai Zhang yunkai.me at gmail.com
Wed Aug 15 20:36:45 CEST 2012


From: Yunkai Zhang <qiushu.zyk at taobao.com>

add tailing '\0' to hex buffer

Signed-off-by: Yunkai Zhang <qiushu.zyk at taobao.com>
---
 sheep/farm/sha1_file.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sheep/farm/sha1_file.c b/sheep/farm/sha1_file.c
index b0abc16..493ca79 100644
--- a/sheep/farm/sha1_file.c
+++ b/sheep/farm/sha1_file.c
@@ -270,5 +270,6 @@ char *sha1_to_hex(const unsigned char *sha1)
 		*buf++ = hex[val >> 4];
 		*buf++ = hex[val & 0xf];
 	}
+	buffer[2 * SHA1_LEN] = 0;
 	return buffer;
 }
-- 
1.7.11.4




More information about the sheepdog mailing list