Skip to content

Commit a8997d5

Browse files
committed
govc: fix integer type conversion
Added a check to panic if a value exceeds `math.MaxInt32` in the `Interval` method to prevent out-of-range errors. Signed-off-by: Ryan Johnson <[email protected]>
1 parent 6faf9b2 commit a8997d5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cli/metric/performance.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"flag"
2222
"fmt"
23+
"math"
2324
"strconv"
2425

2526
"github.com/vmware/govmomi/cli/flags"
@@ -88,7 +89,12 @@ func (f *PerformanceFlag) Interval(val int32) int32 {
8889
if err != nil {
8990
panic(err)
9091
}
91-
interval = int32(n)
92+
93+
if n > math.MaxInt32 {
94+
panic(fmt.Errorf("value out of range for int32: %d", n))
95+
} else {
96+
interval = int32(n)
97+
}
9298
}
9399
}
94100

0 commit comments

Comments
 (0)