From 4429756e536949a1c769f0a95f093c08ef937b5e Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Mon, 20 Jun 2005 10:21:35 -0700 Subject: [PATCH 1/4] Fix crash when an entry was added to the mysql.tables_priv table with an empty hostname. (Bug #11330) --- mysql-test/r/grant.result | 4 ++++ mysql-test/t/grant.test | 8 ++++++++ sql/sql_acl.cc | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) 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); From d11ef13ad990ac3d44e923b7b2ddebcb9e0128c7 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Tue, 21 Jun 2005 11:25:51 -0700 Subject: [PATCH 2/4] Restore creation of files for temporary tables in the tmpdir, which was broken by an earlier bug fix. (Bug #11440) --- sql/sql_table.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index e2e6ee23323..a7fd2a0a2bd 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1339,14 +1339,12 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, /* Check if table exists */ if (create_info->options & HA_LEX_CREATE_TMP_TABLE) { - char tmp_table_name[tmp_file_prefix_length+22+22+22+3]; - my_snprintf(tmp_table_name, sizeof(tmp_table_name), "%s%lx_%lx_%x", - tmp_file_prefix, current_pid, thd->thread_id, - thd->tmp_table++); + my_snprintf(path, sizeof(path), "%s%s%lx_%lx_%x%s", + mysql_tmpdir, tmp_file_prefix, current_pid, thd->thread_id, + thd->tmp_table++, reg_ext); if (lower_case_table_names) - my_casedn_str(files_charset_info, tmp_table_name); + my_casedn_str(files_charset_info, path); create_info->table_options|=HA_CREATE_DELAY_KEY_WRITE; - build_table_path(path, sizeof(path), db, tmp_table_name, reg_ext); } else build_table_path(path, sizeof(path), db, alias, reg_ext); From 13773acc1b534ab2edb6701f0c54184ae45d82f3 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Fri, 24 Jun 2005 17:59:19 -0700 Subject: [PATCH 3/4] If mysql_config is a symlink, resolve it before trying to find the lib and include directories relative to where it is located. (Bug #10986) --- scripts/mysql_config.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index a5c8af5ecb2..16e50c044ca 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -60,11 +60,19 @@ fix_path () get_full_path () { - case $1 in - /*) echo "$1";; - ./*) tmp=`pwd`/$1; echo $tmp | sed -e 's;/\./;/;' ;; - *) which $1 ;; - esac + file=$1 + + # if the file is a symlink, try to resolve it + if [ -h $file ]; + then + file=`ls -l $file | awk '{ print $NF }'` + fi + + case $file in + /*) echo "$file";; + */*) tmp=`pwd`/$file; echo $tmp | sed -e 's;/\./;/;' ;; + *) which $file ;; + esac } me=`get_full_path $0` From ac8f9d386412e1893e9e8f20aa821fa75ad78a2b Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Tue, 5 Jul 2005 15:19:04 -0700 Subject: [PATCH 4/4] Fix test cases --- mysql-test/r/grant.result | 3 ++- mysql-test/r/query_cache.result | 1 - mysql-test/t/grant.test | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index 3a793ef55e4..e9e1d4cd620 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -436,6 +436,7 @@ 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'); +insert into tables_priv values ('','test_db','mysqltest_1','test_table','test_grantor',CURRENT_TIMESTAMP,'Select','Select'); flush privileges; delete from tables_priv where host = '' and user = 'mysqltest_1'; +flush privileges; diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index 3af0d4c3704..2884b9b3fe4 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -1057,6 +1057,5 @@ Qcache_inserts 2 show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 - drop table t1; set GLOBAL query_cache_size=0; diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index d80ef638e79..6c38aac1ebd 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -397,6 +397,7 @@ drop database mysqltest; # connection default; use mysql; -insert into tables_priv values ('','mysqltest_1','test_table','test_grantor','',CURRENT_TIMESTAMP,'Select','Select'); +insert into tables_priv values ('','test_db','mysqltest_1','test_table','test_grantor',CURRENT_TIMESTAMP,'Select','Select'); flush privileges; delete from tables_priv where host = '' and user = 'mysqltest_1'; +flush privileges;