Skip to content

Commit b6fd9f1

Browse files
committed
MDEV-28482 SIGSEGV in get_access_value_from_val_int
also check number of columns
1 parent 957ec8b commit b6fd9f1

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

mysql-test/main/grant_repair.result

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,13 @@ insert into mysql.servers values(0,0,0,0,0,0,0,0);
9696
flush privileges;
9797
ERROR HY000: Cannot load from mysql.servers. The table is probably corrupted
9898
alter table mysql.servers add column Owner varchar(512) not null default '';
99+
#
100+
# MDEV-28482 SIGSEGV in get_access_value_from_val_int
101+
#
102+
create temporary table t1 select * from mysql.tables_priv;
103+
alter table mysql.tables_priv drop column timestamp;
104+
flush privileges;
105+
ERROR HY000: Cannot load from mysql.tables_priv. The table is probably corrupted
106+
alter table mysql.tables_priv add column Timestamp timestamp not null default now() on update now() after grantor;
107+
replace mysql.tables_priv select * from t1;
99108
# End of 10.11 tests

mysql-test/main/grant_repair.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,14 @@ insert into mysql.servers values(0,0,0,0,0,0,0,0);
114114
flush privileges;
115115
alter table mysql.servers add column Owner varchar(512) not null default '';
116116

117+
--echo #
118+
--echo # MDEV-28482 SIGSEGV in get_access_value_from_val_int
119+
--echo #
120+
create temporary table t1 select * from mysql.tables_priv;
121+
alter table mysql.tables_priv drop column timestamp;
122+
--error ER_CANNOT_LOAD_FROM_TABLE_V2
123+
flush privileges;
124+
alter table mysql.tables_priv add column Timestamp timestamp not null default now() on update now() after grantor;
125+
replace mysql.tables_priv select * from t1;
126+
117127
--echo # End of 10.11 tests

sql/sql_acl.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,8 @@ class Grant_table_base
901901
break;
902902
}
903903

904-
if (!table->key_info || table->key_info->user_defined_key_parts != pk_parts)
904+
if (num_fields() < min_columns || !table->key_info ||
905+
table->key_info->user_defined_key_parts != pk_parts)
905906
{
906907
my_error(ER_CANNOT_LOAD_FROM_TABLE_V2, MYF(ME_ERROR_LOG),
907908
table->s->db.str, table->s->table_name.str);

0 commit comments

Comments
 (0)