mirror of
https://github.com/MariaDB/server.git
synced 2026-10-23 18:49:29 +03:00
Problem: `Item::val_str()` may return a String that points to the buffer it was given instead of copying the value into it. For eg: CAST(expr AS CHAR) does so when there's nothing to convert, RIGHT() and SUBSTR() when they return a fragment. `Item_copy_string::copy()` hands its own str_value buffer to such a val_str() and then compares String objects, not the buffers behind them, so it doesn't notice the reuse and copies the buffer onto itself. `String::copy()` needs one byte more for the terminating '\0' and adjusting it frees the old buffer before allocating the new one, so the copy reads freed memory. Fix: Add `String::copy_maybe_substring()` to handle a source that points into the destination's buffer. When the whole buffer is reused, only length and character set are taken over. For a fragment, it is moved to the beginning of the buffer without re-allocating using the newly added `Binary_string::bmove_from()`.
63 lines
1.8 KiB
Plaintext
63 lines
1.8 KiB
Plaintext
--source include/not_windows.inc
|
|
--source include/not_embedded.inc
|
|
|
|
#
|
|
# Test that exposes problems in string functions like my_vsnprintf
|
|
#
|
|
|
|
--echo #
|
|
--echo # MDEV-25612 Assertion `to <= end' failed in process_args
|
|
--echo #
|
|
SET SESSION default_master_connection=REPEAT('a',190),lc_messages=ru_ru;
|
|
CHANGE MASTER TO master_host='dummy';
|
|
START SLAVE sql_thread;
|
|
--error ER_SLAVE_MUST_STOP
|
|
CHANGE MASTER TO master_user='user',master_password='pwd';
|
|
STOP SLAVE;
|
|
RESET SLAVE ALL;
|
|
|
|
--echo #
|
|
--echo # MDEV-25754 ASAN: stack-buffer-overflow in Field_newdate::val_str
|
|
--echo #
|
|
|
|
CREATE TABLE t1 (d DATE);
|
|
INSERT INTO t1 VALUES ('1920-03-02'),('2020-12-01');
|
|
SELECT LENGTH(CONCAT_WS(d, ' ')) FROM t1;
|
|
DROP TABLE t1;
|
|
|
|
--echo #
|
|
--echo # MDEV-28315 ASAN stack-buffer-overflow in String::copy_aligned
|
|
--echo #
|
|
|
|
CREATE TABLE t1 (a VARBINARY(128)) CHARACTER SET utf32;
|
|
INSERT INTO t1 VALUES ('South Carolina, Vermont, New Jersey, New Mexico, Wisconsin, Missouri, Delaware');
|
|
CREATE TABLE t2 (b SET('South Carolina', 'Vermont', 'Texas', 'New Mexico', 'Wisconsin', 'Missouri', 'Delaware', 'Wyoming', 'New Jersey', 'Maryland', 'Illinois', 'New York')) CHARACTER SET utf32;
|
|
--error WARN_DATA_TRUNCATED
|
|
INSERT INTO t2 SELECT * FROM t1;
|
|
DROP TABLE t1;
|
|
DROP TABLE t2;
|
|
|
|
--echo #
|
|
--echo # MDEV-40422: MSAN use-of-uninitialized-value in my_convert
|
|
--echo #
|
|
|
|
SET @old_collation_database= @@collation_database;
|
|
SET @@time_zone='+00:00';
|
|
SET timestamp=UNIX_TIMESTAMP('2001-02-03 10:20:30');
|
|
|
|
SET collation_database= 'latin1_swedish_ci';
|
|
SET CHARACTER SET DEFAULT;
|
|
SELECT CAST(MD5(NOW()) AS CHAR),COUNT(*);
|
|
|
|
SET NAMES latin1;
|
|
SELECT CAST(MD5(NOW()) AS CHAR),COUNT(*);
|
|
SELECT CAST(MD5(NOW()) AS CHAR(5)),COUNT(*);
|
|
SELECT RIGHT(CAST(MD5(NOW()) AS CHAR),1),COUNT(*);
|
|
|
|
SET @@collation_database= @old_collation_database;
|
|
SET timestamp=DEFAULT;
|
|
SET time_zone=DEFAULT;
|
|
SET NAMES DEFAULT;
|
|
|
|
--echo # End of 11.8 tests
|