diff options
author | Eugene Kosov <claprix@yandex.ru> | 2019-09-22 21:04:00 +0300 |
---|---|---|
committer | Eugene Kosov <claprix@yandex.ru> | 2019-09-23 19:12:24 +0300 |
commit | e3da362c037af95a85d3054243a4c9a039ceb4b4 (patch) | |
tree | 4cbf17880f8704ad257974928d22baacd4bc0ac9 | |
parent | 5a92ccbaea1bb3973e23846a741f5694a1e687bd (diff) | |
download | mariadb-git-e3da362c037af95a85d3054243a4c9a039ceb4b4.tar.gz |
MDEV-19189 ASAN memcpy-param-overlap in fill_alter_inplace_info upon adding indexes
memmove() should be used instead of memcpy() for overlapping memory regions.
Overlapping memory regions itself here are fine, because code simply removes
one element from arbitrary position of an array.
-rw-r--r-- | mysql-test/suite/innodb/r/instant_alter_index_rename.result | 7 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/instant_alter_index_rename.test | 10 | ||||
-rw-r--r-- | sql/sql_table.cc | 8 |
3 files changed, 21 insertions, 4 deletions
diff --git a/mysql-test/suite/innodb/r/instant_alter_index_rename.result b/mysql-test/suite/innodb/r/instant_alter_index_rename.result index 93bbf6ee193..52051eff0bd 100644 --- a/mysql-test/suite/innodb/r/instant_alter_index_rename.result +++ b/mysql-test/suite/innodb/r/instant_alter_index_rename.result @@ -176,3 +176,10 @@ check table rename_column_and_index; Table Op Msg_type Msg_text test.rename_column_and_index check status OK drop table rename_column_and_index; +# +# MDEV-19189: ASAN memcpy-param-overlap in fill_alter_inplace_info upon adding indexes +# +CREATE TABLE t1 (f1 INT, f2 INT, f3 INT); +ALTER TABLE t1 ADD FOREIGN KEY f (f2) REFERENCES xx(f2); +ALTER TABLE t1 ADD FOREIGN KEY (f2) REFERENCES t1(f2), ADD KEY (f3), ADD KEY (f1); +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/instant_alter_index_rename.test b/mysql-test/suite/innodb/t/instant_alter_index_rename.test index 3150503c815..3a608a00837 100644 --- a/mysql-test/suite/innodb/t/instant_alter_index_rename.test +++ b/mysql-test/suite/innodb/t/instant_alter_index_rename.test @@ -184,3 +184,13 @@ alter table rename_column_and_index show create table rename_column_and_index; check table rename_column_and_index; drop table rename_column_and_index; + + +--echo # +--echo # MDEV-19189: ASAN memcpy-param-overlap in fill_alter_inplace_info upon adding indexes +--echo # + +CREATE TABLE t1 (f1 INT, f2 INT, f3 INT); +ALTER TABLE t1 ADD FOREIGN KEY f (f2) REFERENCES xx(f2); +ALTER TABLE t1 ADD FOREIGN KEY (f2) REFERENCES t1(f2), ADD KEY (f3), ADD KEY (f1); +DROP TABLE t1; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 9e44eefbf9b..cf1be27ef3b 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -7123,10 +7123,10 @@ static bool fill_alter_inplace_info(THD *thd, TABLE *table, bool varchar, --ha_alter_info->index_add_count; --ha_alter_info->index_drop_count; - memcpy(add_buffer + i, add_buffer + i + 1, - sizeof(add_buffer[0]) * (ha_alter_info->index_add_count - i)); - memcpy(drop_buffer + j, drop_buffer + j + 1, - sizeof(drop_buffer[0]) * (ha_alter_info->index_drop_count - j)); + memmove(add_buffer + i, add_buffer + i + 1, + sizeof(add_buffer[0]) * (ha_alter_info->index_add_count - i)); + memmove(drop_buffer + j, drop_buffer + j + 1, + sizeof(drop_buffer[0]) * (ha_alter_info->index_drop_count - j)); --i; // this index once again break; } |