diff options
| author | 2026-06-11 08:21:21 +0000 | |
|---|---|---|
| committer | 2026-06-11 08:21:21 +0000 | |
| commit | b1f08819620a238ba09f8f7199e67cf0c13afc97 (patch) | |
| tree | 14d68be388935c63d0548187b510b1678ccff56e | |
| parent | internal/format/packfile: Fix 9 continuation bytes is needed for the overflow... (diff) | |
internal/format/packfile: Return ErrInvalidHashSize on ParseEntryHeader
| -rw-r--r-- | internal/format/packfile/entry_header.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/internal/format/packfile/entry_header.go b/internal/format/packfile/entry_header.go index 04d529d5..1428600b 100644 --- a/internal/format/packfile/entry_header.go +++ b/internal/format/packfile/entry_header.go @@ -13,6 +13,12 @@ import ( // or declares a size that overflows uint64. var ErrMalformedEntryHeader = errors.New("internal/format/packfile: malformed entry header") +// ErrInvalidHashSize reports that +// a supplied hash size is not a plausible object ID size. +// This indicates a caller bug, +// not malformed pack data. +var ErrInvalidHashSize = errors.New("internal/format/packfile: invalid hash size") + // MaxTypeSizeLen is the maximum encoded length // of the type/size prefix of an entry header. // Every uint64 size is encodable within this bound, @@ -77,7 +83,7 @@ func ParseEntryHeader(data []byte, hashSize int) (EntryHeader, error) { var zero EntryHeader if hashSize <= 0 || hashSize > id.MaxObjectIDSize { - return zero, fmt.Errorf("internal/format/packfile: invalid hash size %d", hashSize) + return zero, fmt.Errorf("%w: %d", ErrInvalidHashSize, hashSize) } if len(data) == 0 { |
