diff options
author | jimw@mysql.com <> | 2005-06-20 10:21:35 -0700 |
---|---|---|
committer | jimw@mysql.com <> | 2005-06-20 10:21:35 -0700 |
commit | 4429756e536949a1c769f0a95f093c08ef937b5e (patch) | |
tree | a4abbba60a9ce634a6c87e0ebbebf7d2abb41134 | |
parent | b5b3b32d0a7e1577347f4250cb1407d16dbf1316 (diff) | |
download | mariadb-git-4429756e536949a1c769f0a95f093c08ef937b5e.tar.gz |
Fix crash when an entry was added to the mysql.tables_priv
table with an empty hostname. (Bug #11330)
-rw-r--r-- | mysql-test/r/grant.result | 4 | ||||
-rw-r--r-- | mysql-test/t/grant.test | 8 | ||||
-rw-r--r-- | sql/sql_acl.cc | 3 |
3 files changed, 14 insertions, 1 deletions
diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index bb37480aaf8..3a793ef55e4 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -435,3 +435,7 @@ ERROR 42000: INSERT,CREATE command denied to user 'mysqltest_1'@'localhost' for revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; delete from mysql.user where user=_binary'mysqltest_1'; drop database mysqltest; +use mysql; +insert into tables_priv values ('','mysqltest_1','test_table','test_grantor','',CURRENT_TIMESTAMP,'Select','Select'); +flush privileges; +delete from tables_priv where host = '' and user = 'mysqltest_1'; diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 1c8fbe0ff0d..d80ef638e79 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -392,3 +392,11 @@ revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; delete from mysql.user where user=_binary'mysqltest_1'; drop database mysqltest; +# +# Bug #11330: Entry in tables_priv with host = '' causes crash +# +connection default; +use mysql; +insert into tables_priv values ('','mysqltest_1','test_table','test_grantor','',CURRENT_TIMESTAMP,'Select','Select'); +flush privileges; +delete from tables_priv where host = '' and user = 'mysqltest_1'; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 849192154da..d191da32189 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1866,7 +1866,8 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs) if (cols) { int key_len; - col_privs->field[0]->store(host.hostname,(uint) strlen(host.hostname), + col_privs->field[0]->store(host.hostname, + host.hostname ? (uint) strlen(host.hostname) : 0, &my_charset_latin1); col_privs->field[1]->store(db,(uint) strlen(db), &my_charset_latin1); col_privs->field[2]->store(user,(uint) strlen(user), &my_charset_latin1); |