[PATCH 02/17] tree-walk: replace hard-coded constants with the_hash_algo
- From
brian m. carlson <sandals@crustytoothpaste.net>
- Date
- Jul 8, 2018, 23:36 UTC
- Message-ID
- <20180708233638.520172-3-sandals@crustytoothpaste.net>
- In-Reply-To
- <20180708233638.520172-1-sandals@crustytoothpaste.net>
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> --- tree-walk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tree-walk.c b/tree-walk.c index 8f5090862b..c1f27086a9 100644 --- a/tree-walk.c +++ b/tree-walk.c @@ -26,8 +26,9 @@ static int decode_tree_entry(struct tree_desc *desc, const char *buf, unsigned l { const char *path; unsigned int mode, len; + const unsigned hashsz = the_hash_algo->rawsz; - if (size < 23 || buf[size - 21]) { + if (size < hashsz + 3 || buf[size - (hashsz + 1)]) { strbuf_addstr(err, _("too-short tree object")); return -1; }