Commit 8145b308 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-30826 Invalid data on mysql.host segfaults the server after an upgrade to 10.4

convert empty host.db to "%", just as it's done for host.hostname
(in update_hostname())
parent 2ac83283
...@@ -453,4 +453,13 @@ insert mysql.host values (1); ...@@ -453,4 +453,13 @@ insert mysql.host values (1);
flush privileges; flush privileges;
ERROR HY000: Fatal error: mysql.host table is damaged or in unsupported 3.20 format ERROR HY000: Fatal error: mysql.host table is damaged or in unsupported 3.20 format
drop table mysql.host; drop table mysql.host;
#
# MDEV-30826 Invalid data on mysql.host segfaults the server after an upgrade to 10.4
#
create table mysql.host (host char(60) binary default '' not null, db char(64) binary default '' not null, select_priv enum('n','y') collate utf8_general_ci default 'n' not null, insert_priv enum('n','y') collate utf8_general_ci default 'n' not null, update_priv enum('n','y') collate utf8_general_ci default 'n' not null, delete_priv enum('n','y') collate utf8_general_ci default 'n' not null, create_priv enum('n','y') collate utf8_general_ci default 'n' not null, drop_priv enum('n','y') collate utf8_general_ci default 'n' not null, grant_priv enum('n','y') collate utf8_general_ci default 'n' not null, references_priv enum('n','y') collate utf8_general_ci default 'n' not null, index_priv enum('n','y') collate utf8_general_ci default 'n' not null, alter_priv enum('n','y') collate utf8_general_ci default 'n' not null, create_tmp_table_priv enum('n','y') collate utf8_general_ci default 'n' not null, lock_tables_priv enum('n','y') collate utf8_general_ci default 'n' not null, create_view_priv enum('n','y') collate utf8_general_ci default 'n' not null, show_view_priv enum('n','y') collate utf8_general_ci default 'n' not null, create_routine_priv enum('n','y') collate utf8_general_ci default 'n' not null, alter_routine_priv enum('n','y') collate utf8_general_ci default 'n' not null, execute_priv enum('n','y') collate utf8_general_ci default 'n' not null, trigger_priv enum('n','y') collate utf8_general_ci default 'n' not null, primary key /*host*/ (host,db)) engine=myisam character set utf8 collate utf8_bin comment='host privileges; merged with database privileges';
insert mysql.host values('10.5.0.0/255.255.0.0','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','N');
flush privileges;
drop table mysql.host;
#
# End of 10.4 tests # End of 10.4 tests
#
...@@ -408,4 +408,16 @@ insert mysql.host values (1); ...@@ -408,4 +408,16 @@ insert mysql.host values (1);
flush privileges; flush privileges;
drop table mysql.host; drop table mysql.host;
--echo #
--echo # MDEV-30826 Invalid data on mysql.host segfaults the server after an upgrade to 10.4
--echo #
# from mysql_system_tables.sql in 10.3:
create table mysql.host (host char(60) binary default '' not null, db char(64) binary default '' not null, select_priv enum('n','y') collate utf8_general_ci default 'n' not null, insert_priv enum('n','y') collate utf8_general_ci default 'n' not null, update_priv enum('n','y') collate utf8_general_ci default 'n' not null, delete_priv enum('n','y') collate utf8_general_ci default 'n' not null, create_priv enum('n','y') collate utf8_general_ci default 'n' not null, drop_priv enum('n','y') collate utf8_general_ci default 'n' not null, grant_priv enum('n','y') collate utf8_general_ci default 'n' not null, references_priv enum('n','y') collate utf8_general_ci default 'n' not null, index_priv enum('n','y') collate utf8_general_ci default 'n' not null, alter_priv enum('n','y') collate utf8_general_ci default 'n' not null, create_tmp_table_priv enum('n','y') collate utf8_general_ci default 'n' not null, lock_tables_priv enum('n','y') collate utf8_general_ci default 'n' not null, create_view_priv enum('n','y') collate utf8_general_ci default 'n' not null, show_view_priv enum('n','y') collate utf8_general_ci default 'n' not null, create_routine_priv enum('n','y') collate utf8_general_ci default 'n' not null, alter_routine_priv enum('n','y') collate utf8_general_ci default 'n' not null, execute_priv enum('n','y') collate utf8_general_ci default 'n' not null, trigger_priv enum('n','y') collate utf8_general_ci default 'n' not null, primary key /*host*/ (host,db)) engine=myisam character set utf8 collate utf8_bin comment='host privileges; merged with database privileges';
insert mysql.host values('10.5.0.0/255.255.0.0','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','N');
flush privileges;
drop table mysql.host;
--echo #
--echo # End of 10.4 tests --echo # End of 10.4 tests
--echo #
...@@ -2437,6 +2437,8 @@ static bool acl_load(THD *thd, const Grant_tables& tables) ...@@ -2437,6 +2437,8 @@ static bool acl_load(THD *thd, const Grant_tables& tables)
"possible to remove this privilege using REVOKE.", "possible to remove this privilege using REVOKE.",
host.host.hostname, host.db); host.host.hostname, host.db);
} }
else if (!host.db)
host.db= const_cast<char*>(host_not_specified.str);
host.access= host_table.get_access(); host.access= host_table.get_access();
host.access= fix_rights_for_db(host.access); host.access= fix_rights_for_db(host.access);
host.sort= get_magic_sort("hd", host.host.hostname, host.db); host.sort= get_magic_sort("hd", host.host.hostname, host.db);
...@@ -2445,8 +2447,7 @@ static bool acl_load(THD *thd, const Grant_tables& tables) ...@@ -2445,8 +2447,7 @@ static bool acl_load(THD *thd, const Grant_tables& tables)
{ {
sql_print_warning("'host' entry '%s|%s' " sql_print_warning("'host' entry '%s|%s' "
"ignored in --skip-name-resolve mode.", "ignored in --skip-name-resolve mode.",
safe_str(host.host.hostname), host.host.hostname, host.db);
safe_str(host.db));
continue; continue;
} }
#ifndef TO_BE_REMOVED #ifndef TO_BE_REMOVED
...@@ -3533,7 +3534,7 @@ ulong acl_get(const char *host, const char *ip, ...@@ -3533,7 +3534,7 @@ ulong acl_get(const char *host, const char *ip,
ACL_HOST *acl_host=dynamic_element(&acl_hosts,i,ACL_HOST*); ACL_HOST *acl_host=dynamic_element(&acl_hosts,i,ACL_HOST*);
if (compare_hostname(&acl_host->host,host,ip)) if (compare_hostname(&acl_host->host,host,ip))
{ {
if (!acl_host->db || !wild_compare(db,acl_host->db,db_is_pattern)) if (!wild_compare(db, acl_host->db, db_is_pattern))
{ {
host_access=acl_host->access; // Fully specified. Take it host_access=acl_host->access; // Fully specified. Take it
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