tree-walk: replace hard-coded constants with the_hash_algo
Remove the hard-coded 20-based values and replace them with uses of the_hash_algo. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Jul 16, 2018 at 01:27 UTC
83e4b7571c7d78e8236ad87519b75a90e7902a34
1 file changed
+2
-1
tree-walk.c
+2
-1
@@ -26,8 +26,9 @@ static int decode_tree_entry(struct tree_desc *desc, const char *buf, unsigned l
26
{
27
const char *path;
28
unsigned int mode, len;
29
+ const unsigned hashsz = the_hash_algo->rawsz;
30
30
- if (size < 23 || buf[size - 21]) {
31
+ if (size < hashsz + 3 || buf[size - (hashsz + 1)]) {
32
strbuf_addstr(err, _("too-short tree object"));
33
return -1;
34
}