diff --git a/weed/storage/disk_location_ec.go b/weed/storage/disk_location_ec.go index 983865424..ace6ddc15 100644 --- a/weed/storage/disk_location_ec.go +++ b/weed/storage/disk_location_ec.go @@ -2,6 +2,7 @@ package storage import ( "fmt" + "math" "os" "path" "regexp" @@ -124,6 +125,11 @@ func (l *DiskLocation) loadEcShards(shards []string, collection string, vid need return fmt.Errorf("failed to parse ec shard name %v: %w", shard, err) } + // Bounds check for uint8 (ShardId) + if shardId < 0 || shardId > int64(math.MaxUint8) { + return fmt.Errorf("ec shard id %v out of bounds for uint8 in shard name %v", shardId, shard) + } + _, err = l.LoadEcShard(collection, vid, erasure_coding.ShardId(shardId), generation) if err != nil { return fmt.Errorf("failed to load ec shard %v: %w", shard, err)