From 2a05a6ba87d0b4d62de6e137b3287d59d583c947 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 9 Jan 2006 10:31:07 +0100 Subject: [PATCH 1/2] Bug #15598 Server crashes in specific case during setting new password - When acl_user->host.hostname is NULL compare it as "" --- mysql-test/r/grant.result | 9 +++++++++ mysql-test/t/grant.test | 12 ++++++++++++ sql/sql_acl.cc | 5 +++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index 0a406c1ffc2..13593ec2a88 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -464,3 +464,12 @@ show grants for root@localhost; Grants for root@localhost GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION set names latin1; +insert into mysql.user (host, user) values ('', 'mysqltest_7'); +flush privileges; +set password for mysqltest_7@ = password('systpass'); +show grants for mysqltest_7@; +Grants for mysqltest_7@ +GRANT USAGE ON *.* TO 'mysqltest_7'@'' IDENTIFIED BY PASSWORD '*2FB071A056F9BB745219D9C876814231DAF46517' +drop user mysqltest_7@; +show grants for mysqltest_7@; +ERROR 42000: There is no such grant defined for user 'mysqltest_7' on host '' diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 039e41dcf34..805fa881399 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -421,4 +421,16 @@ revoke all privileges on show grants for root@localhost; set names latin1; +# +# Bug #15598 Server crashes in specific case during setting new password +# - Caused by a user with host '' +# +insert into mysql.user (host, user) values ('', 'mysqltest_7'); +flush privileges; +set password for mysqltest_7@ = password('systpass'); +show grants for mysqltest_7@; +drop user mysqltest_7@; +--error 1141 +show grants for mysqltest_7@; + # End of 4.1 tests diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 1ade6ce3064..119952eeda9 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1371,7 +1371,8 @@ find_acl_user(const char *host, const char *user, my_bool exact) acl_user->user && !strcmp(user,acl_user->user)) { if (exact ? !my_strcasecmp(&my_charset_latin1, host, - acl_user->host.hostname) : + acl_user->host.hostname ? + acl_user->host.hostname : "") : compare_hostname(&acl_user->host,host,host)) { DBUG_RETURN(acl_user); @@ -3604,7 +3605,7 @@ ACL_USER *check_acl_user(LEX_USER *user_name, if (!(user=acl_user->user)) user= ""; if (!(host=acl_user->host.hostname)) - host= "%"; + host= ""; if (!strcmp(user_name->user.str,user) && !my_strcasecmp(system_charset_info, user_name->host.str, host)) break; From 4bcf14179900eb3ee0b91957c71a303261c1fc93 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 9 Jan 2006 17:12:26 +0100 Subject: [PATCH 2/2] Bug #15598 Server crashes in specific case during setting new password - Comparing host string against NULL caused crash. - If host.hostname is NULL treat it as "" --- mysql-test/r/grant.result | 18 +++++++++--------- mysql-test/t/grant.test | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index 304294057d7..eea29161de8 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -437,15 +437,6 @@ delete from mysql.columns_priv where user="mysqltest_3"; flush privileges; drop database mysqltest_1; drop database mysqltest_2; -insert into mysql.user (host, user) values ('', 'mysqltest_7'); -flush privileges; -set password for mysqltest_7@ = password('systpass'); -show grants for mysqltest_7@; -Grants for mysqltest_7@ -GRANT USAGE ON *.* TO 'mysqltest_7'@'' IDENTIFIED BY PASSWORD '*2FB071A056F9BB745219D9C876814231DAF46517' -drop user mysqltest_7@; -show grants for mysqltest_7@; -ERROR 42000: There is no such grant defined for user 'mysqltest_7' on host '' SHOW PRIVILEGES; Privilege Context Comment Alter Tables To alter the table @@ -624,3 +615,12 @@ show grants for root@localhost; Grants for root@localhost GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION set names latin1; +create user mysqltest_7@; +set password for mysqltest_7@ = password('systpass'); +show grants for mysqltest_7@; +Grants for mysqltest_7@ +GRANT USAGE ON *.* TO 'mysqltest_7'@'' IDENTIFIED BY PASSWORD '*2FB071A056F9BB745219D9C876814231DAF46517' +drop user mysqltest_7@; +flush privileges; +show grants for mysqltest_7@; +ERROR 42000: There is no such grant defined for user 'mysqltest_7' on host '' diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index d8deb379cd4..9a8b7a19c59 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -503,11 +503,11 @@ set names latin1; # Bug #15598 Server crashes in specific case during setting new password # - Caused by a user with host '' # -insert into mysql.user (host, user) values ('', 'mysqltest_7'); -flush privileges; +create user mysqltest_7@; set password for mysqltest_7@ = password('systpass'); show grants for mysqltest_7@; drop user mysqltest_7@; +flush privileges; # BUG#16297(flush should be removed when that bug is fixed) --error 1141 show grants for mysqltest_7@;