Re: [PATCH 1/2] use SHA_DIGEST_LENGTH
From: David Rientjes <hidden>
Date: 2016-06-15 22:42:41
Subsystem:
the rest · Maintainer:
Linus Torvalds
On Sat, 23 Sep 2006, David Rientjes wrote:
quoted hunk
@@ -202,16 +202,17 @@ int cmd_name_rev(int argc, const char ** #define ishex(x) (isdigit((x)) || ((x) >= 'a' && (x) <= 'f')) if (!ishex(*p)) forty = 0; - else if (++forty == 40 && + else if (++forty == 2 * SHA_DIGEST_LENGTH && !ishex(*(p+1))) { - unsigned char sha1[40]; + unsigned char sha1[2 * SHA_DIGEST_LENGTH]; const char *name = "undefined"; char c = *(p+1); forty = 0; *(p+1) = 0; - if (!get_sha1(p - 39, sha1)) { + if (!get_sha1(p - (SHA_DIGEST_LENGTH + 1), + sha1)) { struct object *o = lookup_object(sha1); if (o)
Off by 18 error. Signed-off-by: David Rientjes <redacted> --- builtin-name-rev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin-name-rev.c b/builtin-name-rev.c
index f522664..ed99679 100644
--- a/builtin-name-rev.c
+++ b/builtin-name-rev.c@@ -211,7 +211,7 @@ #define ishex(x) (isdigit((x)) || ((x) > forty = 0; *(p+1) = 0; - if (!get_sha1(p - (SHA_DIGEST_LENGTH + 1), + if (!get_sha1(p - 2 * SHA_DIGEST_LENGTH + 1, sha1)) { struct object *o = lookup_object(sha1);