mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-11-24 16:53:14 +08:00
Fixed CodeQL Security Issue
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user