Skip to content

Commit 389c57f

Browse files
Potential fix for code scanning alert no. 2: Incorrect conversion between integer types
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 47f7faf commit 389c57f

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

cli/widget/multiinput.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package widget
33
import (
44
"context"
55
"fmt"
6+
"math"
67
"strconv"
78

89
"github.com/SAP/xp-clifford/erratt"
@@ -60,7 +61,13 @@ func (c intConverterType) FromType(i int) (string, error) {
6061

6162
func (c intConverterType) ToType(s string) (int, error) {
6263
i, err := strconv.ParseInt(s, 10, 64)
63-
return int(i), err
64+
if err != nil {
65+
return 0, err
66+
}
67+
if i < int64(math.MinInt) || i > int64(math.MaxInt) {
68+
return 0, fmt.Errorf("value %d out of range for int", i)
69+
}
70+
return int(i), nil
6471
}
6572

6673
var IntConverter TypeConverter[int] = intConverterType{}

0 commit comments

Comments
 (0)