aboutsummaryrefslogtreecommitdiff
path: root/weed/admin/dash/volume_management.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/admin/dash/volume_management.go')
-rw-r--r--weed/admin/dash/volume_management.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/weed/admin/dash/volume_management.go b/weed/admin/dash/volume_management.go
index 38b1257a4..c0be958a9 100644
--- a/weed/admin/dash/volume_management.go
+++ b/weed/admin/dash/volume_management.go
@@ -3,6 +3,7 @@ package dash
import (
"context"
"fmt"
+ "math"
"sort"
"time"
@@ -392,8 +393,14 @@ func (s *AdminServer) GetVolumeDetails(volumeID int, server string) (*VolumeDeta
// VacuumVolume performs a vacuum operation on a specific volume
func (s *AdminServer) VacuumVolume(volumeID int, server string) error {
+ // Validate volumeID range before converting to uint32
+ if volumeID < 0 || uint64(volumeID) > math.MaxUint32 {
+ return fmt.Errorf("volume ID out of range: %d", volumeID)
+ }
return s.WithMasterClient(func(client master_pb.SeaweedClient) error {
_, err := client.VacuumVolume(context.Background(), &master_pb.VacuumVolumeRequest{
+ // lgtm[go/incorrect-integer-conversion]
+ // Safe conversion: volumeID has been validated to be in range [0, 0xFFFFFFFF] above
VolumeId: uint32(volumeID),
GarbageThreshold: 0.0001, // A very low threshold to ensure all garbage is collected
Collection: "", // Empty for all collections