Skip to content

Commit 87003d2

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3548726 commit 87003d2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

builtin/get-tar-commit-id.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix)
4141
if (!skip_prefix(end, " comment=", &comment))
4242
return 1;
4343
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)
4546
return 1;
4647

4748
if (write_in_full(1, comment, len) < 0)

0 commit comments

Comments
 (0)