Commit 9e78db81 authored by unknown's avatar unknown

Fix crash when an entry was added to the mysql.tables_priv

table with an empty hostname. (Bug #11330)


mysql-test/r/grant.result:
  Update results
mysql-test/t/grant.test:
  Add new regression test
sql/sql_acl.cc:
  Don't call strlen() on a NULL pointer.
parent 79444fa5
......@@ -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';
......@@ -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';
......@@ -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);
......
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