Skip to content

Commit d6fd497

Browse files
authored
Merge pull request #24 from trimble-oss/alert-autofix-221
Potential fix for code scanning alert no. 221: Incorrect conversion between integer types
2 parents a440633 + fff9988 commit d6fd497

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

sql/system_settype.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package sql
1616

1717
import (
18+
"math"
1819
"reflect"
1920

2021
"github.com/dolthub/vitess/go/sqltypes"
@@ -90,6 +91,9 @@ func (t systemSetType) Convert(v interface{}) (interface{}, error) {
9091
// Float values aren't truly accepted, but the engine will give them when it should give ints.
9192
// Therefore, if the float doesn't have a fractional portion, we treat it as an int.
9293
if value == float64(int64(value)) {
94+
if value < float64(math.MinInt64) || value > float64(math.MaxInt64) {
95+
return nil, ErrInvalidSystemVariableValue.New(t.varName, v)
96+
}
9397
return t.SetType.Convert(int64(value))
9498
}
9599
case decimal.Decimal:

0 commit comments

Comments
 (0)