mirror of
https://github.com/MariaDB/server.git
synced 2025-01-28 17:54:16 +01:00
MDEV-31221 UBSAN runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int' in my_strtoll10_utf32
The code in my_strtoll10_mb2 and my_strtoll10_utf32 could hit undefinite behavior by negation of LONGLONG_MIN. Fixing to avoid this. Also, fixing my_strtoll10() in the same style. The previous reduction produced a redundant warning on CAST(_latin1'-9223372036854775808' AS SIGNED)
This commit is contained in:
parent
841dc07ee1
commit
9ac8172ac3
8 changed files with 51 additions and 1 deletions
|
@ -8975,5 +8975,11 @@ CAST(_latin1 0x61FF62 AS INT)
|
||||||
Warnings:
|
Warnings:
|
||||||
Warning 1292 Truncated incorrect INTEGER value: 'aÿb'
|
Warning 1292 Truncated incorrect INTEGER value: 'aÿb'
|
||||||
#
|
#
|
||||||
|
# MDEV-31221 UBSAN runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int' in my_strtoll10_utf32
|
||||||
|
#
|
||||||
|
SELECT CAST(CONVERT('-9223372036854775808' USING latin1) AS SIGNED) AS c1;
|
||||||
|
c1
|
||||||
|
-9223372036854775808
|
||||||
|
#
|
||||||
# End of 10.5 tests
|
# End of 10.5 tests
|
||||||
#
|
#
|
||||||
|
|
|
@ -501,6 +501,13 @@ SELECT CAST(_latin1 0x617E62 AS INT);
|
||||||
SELECT CAST(_latin1 0x61FF62 AS INT);
|
SELECT CAST(_latin1 0x61FF62 AS INT);
|
||||||
|
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-31221 UBSAN runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int' in my_strtoll10_utf32
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
SELECT CAST(CONVERT('-9223372036854775808' USING latin1) AS SIGNED) AS c1;
|
||||||
|
|
||||||
|
|
||||||
--echo #
|
--echo #
|
||||||
--echo # End of 10.5 tests
|
--echo # End of 10.5 tests
|
||||||
--echo #
|
--echo #
|
||||||
|
|
|
@ -6549,5 +6549,11 @@ OCT(c)
|
||||||
1000000000000000000000
|
1000000000000000000000
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
#
|
#
|
||||||
|
# MDEV-31221 UBSAN runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int' in my_strtoll10_utf32
|
||||||
|
#
|
||||||
|
SELECT CAST(CONVERT('-9223372036854775808' USING ucs2) AS SIGNED) AS c1;
|
||||||
|
c1
|
||||||
|
-9223372036854775808
|
||||||
|
#
|
||||||
# End of 10.5 tests
|
# End of 10.5 tests
|
||||||
#
|
#
|
||||||
|
|
|
@ -1226,6 +1226,11 @@ INSERT INTO t1 VALUES ('-9223372036854775808.5');
|
||||||
SELECT OCT(c) FROM t1;
|
SELECT OCT(c) FROM t1;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-31221 UBSAN runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int' in my_strtoll10_utf32
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
SELECT CAST(CONVERT('-9223372036854775808' USING ucs2) AS SIGNED) AS c1;
|
||||||
|
|
||||||
--echo #
|
--echo #
|
||||||
--echo # End of 10.5 tests
|
--echo # End of 10.5 tests
|
||||||
|
|
|
@ -3024,3 +3024,12 @@ HEX(DATE_FORMAT(TIME'11:22:33',@format))
|
||||||
#
|
#
|
||||||
# End of 10.4 tests
|
# End of 10.4 tests
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
# MDEV-31221 UBSAN runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int' in my_strtoll10_utf32
|
||||||
|
#
|
||||||
|
SELECT CAST(CONVERT('-9223372036854775808' USING utf32) AS SIGNED) AS c1;
|
||||||
|
c1
|
||||||
|
-9223372036854775808
|
||||||
|
#
|
||||||
|
# End of 10.5 tests
|
||||||
|
#
|
||||||
|
|
|
@ -1162,3 +1162,14 @@ SELECT HEX(DATE_FORMAT(TIME'11:22:33',@format));
|
||||||
--echo #
|
--echo #
|
||||||
|
|
||||||
--enable_service_connection
|
--enable_service_connection
|
||||||
|
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-31221 UBSAN runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int' in my_strtoll10_utf32
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
SELECT CAST(CONVERT('-9223372036854775808' USING utf32) AS SIGNED) AS c1;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # End of 10.5 tests
|
||||||
|
--echo #
|
||||||
|
|
|
@ -1011,6 +1011,8 @@ end4:
|
||||||
{
|
{
|
||||||
if (li > MAX_NEGATIVE_NUMBER)
|
if (li > MAX_NEGATIVE_NUMBER)
|
||||||
goto overflow;
|
goto overflow;
|
||||||
|
if (li == MAX_NEGATIVE_NUMBER) // Avoid undefinite behavior in negation
|
||||||
|
return LONGLONG_MIN;
|
||||||
return -((longlong) li);
|
return -((longlong) li);
|
||||||
}
|
}
|
||||||
return (longlong) li;
|
return (longlong) li;
|
||||||
|
@ -2574,6 +2576,8 @@ end4:
|
||||||
{
|
{
|
||||||
if (li > MAX_NEGATIVE_NUMBER)
|
if (li > MAX_NEGATIVE_NUMBER)
|
||||||
goto overflow;
|
goto overflow;
|
||||||
|
if (li == MAX_NEGATIVE_NUMBER) // Avoid undefinite behavior in negation
|
||||||
|
return LONGLONG_MIN;
|
||||||
return -((longlong) li);
|
return -((longlong) li);
|
||||||
}
|
}
|
||||||
return (longlong) li;
|
return (longlong) li;
|
||||||
|
|
|
@ -241,8 +241,10 @@ end4:
|
||||||
*endptr= (char*) s;
|
*endptr= (char*) s;
|
||||||
if (negative)
|
if (negative)
|
||||||
{
|
{
|
||||||
if (li >= MAX_NEGATIVE_NUMBER) // Avoid undefined behavior
|
if (li > MAX_NEGATIVE_NUMBER)
|
||||||
goto overflow;
|
goto overflow;
|
||||||
|
if (li == MAX_NEGATIVE_NUMBER) // Avoid undefined behavior
|
||||||
|
return LONGLONG_MIN;
|
||||||
return -((longlong) li);
|
return -((longlong) li);
|
||||||
}
|
}
|
||||||
return (longlong) li;
|
return (longlong) li;
|
||||||
|
|
Loading…
Add table
Reference in a new issue