Skip to content

Commit b7eeb3c

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

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sql/system_enumtype.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,19 @@ func (t systemEnumType) Convert(v interface{}) (interface{}, error) {
9494
case int64:
9595
return t.Convert(int(value))
9696
case uint64:
97-
return t.Convert(int(value))
97+
if value <= math.MaxInt {
98+
return t.Convert(int(value))
99+
}
100+
return nil, ErrInvalidSystemVariableValue.New(t.varName, value)
98101
case float32:
99102
return t.Convert(float64(value))
100103
case float64:
101104
// Float values aren't truly accepted, but the engine will give them when it should give ints.
102105
// Therefore, if the float doesn't have a fractional portion, we treat it as an int.
103-
if value == float64(int(value)) {
106+
if value == float64(int(value)) && value <= float64(math.MaxInt) {
104107
return t.Convert(int(value))
105108
}
109+
return nil, ErrInvalidSystemVariableValue.New(t.varName, value)
106110
case decimal.Decimal:
107111
f, _ := value.Float64()
108112
return t.Convert(f)

0 commit comments

Comments
 (0)