From 6002485582541df9dff3e2c782a014564e22ed07 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Tue, 27 Jan 2026 19:05:00 +0100 Subject: hash: Use a hashAlgorithmDetails struct for single source of truth hashAlgorithm's are assumed to be valid; methods on invalid hashAlgorithms will panic from out-of-bounds read when it's not found in hashAlgorithmTable and that's expected and intended. --- pack_pack.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'pack_pack.go') diff --git a/pack_pack.go b/pack_pack.go index 6e0806b1..628fa258 100644 --- a/pack_pack.go +++ b/pack_pack.go @@ -176,7 +176,7 @@ func (repo *Repository) packTypeSizeWithin(pf *packFile, ofs uint64, seen map[pa case ObjectTypeCommit, ObjectTypeTree, ObjectTypeBlob, ObjectTypeTag: return ty, declaredSize, nil case ObjectTypeRefDelta: - hashEnd := dataStart + uint64(repo.hashAlgo.size()) + hashEnd := dataStart + uint64(repo.hashAlgo.Size()) if hashEnd > uint64(len(pf.data)) { return ObjectTypeInvalid, 0, io.ErrUnexpectedEOF } @@ -273,7 +273,7 @@ func (repo *Repository) packBodyResolveWithin(pf *packFile, ofs uint64) (ObjectT resultTy = ty resolved = true case ObjectTypeRefDelta: - hashEnd := dataStart + uint64(repo.hashAlgo.size()) + hashEnd := dataStart + uint64(repo.hashAlgo.Size()) if hashEnd > uint64(len(pf.data)) { return fail(io.ErrUnexpectedEOF) } -- cgit v1.3.1-10-gc9f91