Commit e3da362c authored by Eugene Kosov's avatar Eugene Kosov

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.
parent 5a92ccba
...@@ -176,3 +176,10 @@ check table rename_column_and_index; ...@@ -176,3 +176,10 @@ check table rename_column_and_index;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.rename_column_and_index check status OK test.rename_column_and_index check status OK
drop table rename_column_and_index; 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;
...@@ -184,3 +184,13 @@ alter table rename_column_and_index ...@@ -184,3 +184,13 @@ alter table rename_column_and_index
show create table rename_column_and_index; show create table rename_column_and_index;
check table rename_column_and_index; check table rename_column_and_index;
drop 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;
...@@ -7123,10 +7123,10 @@ static bool fill_alter_inplace_info(THD *thd, TABLE *table, bool varchar, ...@@ -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_add_count;
--ha_alter_info->index_drop_count; --ha_alter_info->index_drop_count;
memcpy(add_buffer + i, add_buffer + i + 1, memmove(add_buffer + i, add_buffer + i + 1,
sizeof(add_buffer[0]) * (ha_alter_info->index_add_count - i)); sizeof(add_buffer[0]) * (ha_alter_info->index_add_count - i));
memcpy(drop_buffer + j, drop_buffer + j + 1, memmove(drop_buffer + j, drop_buffer + j + 1,
sizeof(drop_buffer[0]) * (ha_alter_info->index_drop_count - j)); sizeof(drop_buffer[0]) * (ha_alter_info->index_drop_count - j));
--i; // this index once again --i; // this index once again
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment