builtin/get-tar-commit-id: make hash size independent
To make this code independent of the hash size, verify that the length of the comment is equal to that of any supported hash algorithm. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Feb 19, 2019 at 00:05 UTC
87003d2c94985f9b3c5ef23b9c042ae3b4ede6bb
1 file changed
+2
-1
builtin/get-tar-commit-id.c
+2
-1
@@ -41,7 +41,8 @@ int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix)
41
if (!skip_prefix(end, " comment=", &comment))
42
return 1;
43
len -= comment - content;
44
- if (len != GIT_SHA1_HEXSZ + 1)
44
+ if (len < 1 || !(len % 2) ||
45
+ hash_algo_by_length((len - 1) / 2) == GIT_HASH_UNKNOWN)
46
return 1;
47
48
if (write_in_full(1, comment, len) < 0)