Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2019-02-19 03:05:19 +0300
committerJunio C Hamano <gitster@pobox.com>2019-04-01 05:57:39 +0300
commit87003d2c94985f9b3c5ef23b9c042ae3b4ede6bb (patch)
tree2b8b0ca9938deb953df5ae6733196a6c99ad9c91 /builtin/get-tar-commit-id.c
parent3548726cd7f5c5d2d8a1359ac21ae0354bd4c895 (diff)
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>
Diffstat (limited to 'builtin/get-tar-commit-id.c')
-rw-r--r--builtin/get-tar-commit-id.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/builtin/get-tar-commit-id.c b/builtin/get-tar-commit-id.c
index 312e44ed05f..491af9202dc 100644
--- a/builtin/get-tar-commit-id.c
+++ b/builtin/get-tar-commit-id.c
@@ -41,7 +41,8 @@ int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix)
if (!skip_prefix(end, " comment=", &comment))
return 1;
len -= comment - content;
- if (len != GIT_SHA1_HEXSZ + 1)
+ if (len < 1 || !(len % 2) ||
+ hash_algo_by_length((len - 1) / 2) == GIT_HASH_UNKNOWN)
return 1;
if (write_in_full(1, comment, len) < 0)