From 3c5bf9fef759d3e736df57f78ed70ccd83de2b51 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Thu, 11 Jun 2026 13:50:28 +0000 Subject: internal/format/packidx: Fix lints --- internal/format/packidx/lookup.go | 2 +- internal/format/packidx/packidx.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'internal/format') diff --git a/internal/format/packidx/lookup.go b/internal/format/packidx/lookup.go index 5135a5de..d1293f47 100644 --- a/internal/format/packidx/lookup.go +++ b/internal/format/packidx/lookup.go @@ -53,7 +53,7 @@ func (idx *Packidx) OffsetAt(pos int) (uint64, error) { } slot := raw &^ largeOffsetFlag - if slot >= idx.off64Count { + if uint64(slot) >= idx.off64Count { return 0, fmt.Errorf("%w: 64-bit offset reference out of range", ErrMalformedPackIndex) } diff --git a/internal/format/packidx/packidx.go b/internal/format/packidx/packidx.go index a488279a..ef2c93f4 100644 --- a/internal/format/packidx/packidx.go +++ b/internal/format/packidx/packidx.go @@ -47,7 +47,7 @@ type Packidx struct { off32Off int off64Off int // off64Count is the number of 64-bit offset table entries. - off64Count uint32 + off64Count uint64 } // Parse parses one pack index from data. @@ -75,6 +75,7 @@ func Parse(data []byte, hashSize int) (Packidx, error) { } prev := uint32(0) + for i := range 256 { count := binary.BigEndian.Uint32(data[headerLen+4*i:]) if count < prev { @@ -116,7 +117,7 @@ func Parse(data []byte, hashSize int) (Packidx, error) { idx := Packidx{ data: data, hashSize: hashSize, - off64Count: uint32(off64Count), + off64Count: off64Count, } idx.numObjects, err = intconv.Uint64ToInt(numObjects) -- cgit v1.3.1-10-gc9f91