Skip to content

Commit f37f416

Browse files
committed
fix unsigned int overflow
1 parent 004ef0f commit f37f416

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

packets.go

+9-7
Original file line numberDiff line numberDiff line change
@@ -827,15 +827,17 @@ func (rows *textRows) readRow(dest []driver.Value) error {
827827
dest[i] = buf
828828
}
829829

830-
case fieldTypeTiny, fieldTypeShort, fieldTypeInt24, fieldTypeYear, fieldTypeLong:
830+
case fieldTypeTiny, fieldTypeShort, fieldTypeInt24, fieldTypeYear:
831831
dest[i], err = strconv.ParseInt(string(buf), 10, 32)
832832

833-
//case fieldTypeLong:
834-
// if rows.rs.columns[i].flags&flagUnsigned != 0 {
835-
// dest[i], err = strconv.ParseUint(string(buf), 10, 32)
836-
// } else {
837-
// dest[i], err = strconv.ParseInt(string(buf), 10, 32)
838-
// }
833+
case fieldTypeLong:
834+
if rows.rs.columns[i].flags&flagUnsigned != 0 {
835+
var d uint64
836+
d, err = strconv.ParseUint(string(buf), 10, 32)
837+
dest[i] = int64(d)
838+
} else {
839+
dest[i], err = strconv.ParseInt(string(buf), 10, 32)
840+
}
839841

840842
case fieldTypeLongLong:
841843
if rows.rs.columns[i].flags&flagUnsigned != 0 {

0 commit comments

Comments
 (0)