aboutsummaryrefslogtreecommitdiff
path: root/pack_midx.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2025-11-16 00:00:00 +0000
committerGravatar Runxi Yu2025-11-16 00:00:00 +0000
commitbd91bf5f3bcffe5d1023ab9a37e4a9425830aba9 (patch)
treee6e9fb33bfa5c455a824f0af065c54529d357c0c /pack_midx.go
parentRevert "hash: Generic hash-algorithm API" (diff)
signature
hash: Make fewer helper functions need explicit hash length fields
Diffstat (limited to 'pack_midx.go')
-rw-r--r--pack_midx.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/pack_midx.go b/pack_midx.go
index 7f31e565..0c4f3213 100644
--- a/pack_midx.go
+++ b/pack_midx.go
@@ -1,6 +1,7 @@
package furgit
import (
+ "fmt"
"os"
"path/filepath"
"strings"
@@ -245,7 +246,12 @@ func (midx *multiPackIndex) lookup(id Hash) (packlocation, error) {
}
}
- first := int(id[0])
+ // Verify hash size matches repository hash size
+ if id.size != midx.repo.HashSize {
+ return packlocation{}, fmt.Errorf("furgit: hash size mismatch: got %d, expected %d", id.size, midx.repo.HashSize)
+ }
+
+ first := int(id.data[0])
var lo int
if first > 0 {
lo = int(readBE32(midx.fanout[(first-1)*4 : first*4]))