Skip to content

Commit e970eaf

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

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sql/system_inttype.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package sql
1717
import (
1818
"reflect"
1919
"strconv"
20+
"math"
2021

2122
"github.com/shopspring/decimal"
2223

@@ -99,8 +100,11 @@ func (t systemIntType) Convert(v interface{}) (interface{}, error) {
99100
// Therefore, if the float doesn't have a fractional portion, we treat it as an int.
100101
if value == float64(int64(value)) {
101102
if value >= float64(t.lowerbound) && value <= float64(t.upperbound) {
102-
intVal := int64(value)
103-
return t.Convert(intVal)
103+
if value >= float64(math.MinInt64) && value <= float64(math.MaxInt64) {
104+
intVal := int64(value)
105+
return t.Convert(intVal)
106+
}
107+
return nil, ErrInvalidSystemVariableValue.New(t.varName, v)
104108
}
105109
return nil, ErrInvalidSystemVariableValue.New(t.varName, v)
106110
}

0 commit comments

Comments
 (0)