提交 3c3852e3 编写于 作者: L Linus Torvalds 提交者: Junio C Hamano

[PATCH] Make get_sha1_basic() more careful

The "get_sha1_hex()" function is designed to work with SHA1 hex strings
that may be followed by arbitrary crud. However, that's not acceptable for
"get_sha1()" which is used for command line arguments etc: we don't want
to silently allow random characters after the end of the SHA1.

So verify that the hex string is all we have.
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
Signed-off-by: NJunio C Hamano <junkio@cox.net>
上级 02a4a32c
......@@ -148,7 +148,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
};
const char **p;
if (!get_sha1_hex(str, sha1))
if (len == 40 && !get_sha1_hex(str, sha1))
return 0;
for (p = prefix; *p; p++) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册