mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
A fix and a test case for Bug#34166 Server crash in SHOW OPEN TABLES and
pre-locking. The crash was caused by an implicit assumption in check_table_access() that table_list parameter is always a part of lex->query_tables. When iterating over the passed list of tables, check_table_access() used to stop only when lex->query_tables_last_not_own was reached. In case of pre-locking, lex->query_tables_last_own is not NULL and points to some element of lex->query_tables. When the parameter of check_table_access() was not part of lex->query_tables, loop invariant could never be violated and a crash would happen when the current table pointer would point beyond the end of the provided list. The fix is to change the signature of check_table_access() to also accept a numeric limit of loop iterations, similarly to check_grant(), and supply this limit in all places when we want to check access of tables that are outside lex->query_tables, or just want to check access to one table.
This commit is contained in:
@ -4059,7 +4059,7 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||
proc_tables.table_name= proc_tables.alias= (char*) "proc";
|
||||
proc_tables.table_name_length= 4;
|
||||
proc_tables.lock_type= TL_READ;
|
||||
full_access= !check_table_access(thd, SELECT_ACL, &proc_tables, 1);
|
||||
full_access= !check_table_access(thd, SELECT_ACL, &proc_tables, 1, TRUE);
|
||||
if (!(proc_table= open_proc_table_for_read(thd, &open_tables_state_backup)))
|
||||
{
|
||||
DBUG_RETURN(1);
|
||||
@ -4447,10 +4447,8 @@ static int get_schema_triggers_record(THD *thd, TABLE_LIST *tables,
|
||||
Table_triggers_list *triggers= tables->table->triggers;
|
||||
int event, timing;
|
||||
|
||||
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||
if (check_table_access(thd, TRIGGER_ACL, tables, 1))
|
||||
if (check_table_access(thd, TRIGGER_ACL, tables, 1, TRUE))
|
||||
goto ret;
|
||||
#endif
|
||||
|
||||
for (event= 0; event < (int)TRG_EVENT_MAX; event++)
|
||||
{
|
||||
|
Reference in New Issue
Block a user