1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-28386 UBSAN: runtime error: negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_strntoull_8bit on SELECT ... OCT

The code in my_strntoull_8bit() and my_strntoull_mb2_or_mb4()
could hit undefinite behavior by negating of LONGLONG_MIN.
Fixing the code to avoid this.
This commit is contained in:
Alexander Barkov
2024-09-20 09:23:33 +04:00
parent 0a5e4a0191
commit 841dc07ee1
6 changed files with 52 additions and 2 deletions

View File

@ -2358,6 +2358,19 @@ CREATE TABLE t (c1 INT,c2 CHAR);
SELECT SUBSTR(0,@a) FROM t;
DROP TABLE t;
--echo #
--echo # MDEV-28386 UBSAN: runtime error: negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_strntoull_8bit on SELECT ... OCT
--echo #
CREATE TABLE t1 (c BLOB);
INSERT INTO t1 VALUES ('-9223372036854775808.5');
SELECT OCT(c) FROM t1;
SELECT BIN(c) FROM t1;
DROP TABLE t1;
DO OCT(-9223372036854775808);
--echo #
--echo # End of 10.5 tests
--echo #