Fixed CodeQL Security Issue

This commit is contained in:
chrislu
2025-08-10 17:48:29 -07:00
parent cd75202da8
commit 5bb475c572

View File

@@ -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)