summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGeorgi Kodinov <joro@sun.com>2010-05-03 18:16:51 +0300
committerGeorgi Kodinov <joro@sun.com>2010-05-03 18:16:51 +0300
commitf63608ea97133b12a1a5b78326e5eaddefb4d9b2 (patch)
tree117babc957795701b982e66798d477418011c990 /tests
parent54705ab1762eb305f389d3cf1a16edc88b3361bc (diff)
downloadmariadb-git-f63608ea97133b12a1a5b78326e5eaddefb4d9b2.tar.gz
Bug #53371: COM_FIELD_LIST can be abused to bypass table level grants.
The server was not checking the supplied to COM_FIELD_LIST table name for validity and compliance to acceptable table names standards. Fixed by checking the table name for compliance similar to how it's normally checked by the parser and returning an error message if it's not compliant.
Diffstat (limited to 'tests')
-rw-r--r--tests/mysql_client_test.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 63137bdba93..5b26b96707b 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -16679,6 +16679,47 @@ static void test_bug45010()
}
+static void test_bug53371()
+{
+ int rc;
+ MYSQL_RES *result;
+
+ myheader("test_bug53371");
+
+ rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
+ myquery(rc);
+ rc= mysql_query(mysql, "DROP DATABASE IF EXISTS bug53371");
+ myquery(rc);
+ rc= mysql_query(mysql, "DROP USER 'testbug'@localhost");
+
+ rc= mysql_query(mysql, "CREATE TABLE t1 (a INT)");
+ myquery(rc);
+ rc= mysql_query(mysql, "CREATE DATABASE bug53371");
+ myquery(rc);
+ rc= mysql_query(mysql, "GRANT SELECT ON bug53371.* to 'testbug'@localhost");
+ myquery(rc);
+
+ rc= mysql_change_user(mysql, "testbug", NULL, "bug53371");
+ myquery(rc);
+
+ rc= mysql_query(mysql, "SHOW COLUMNS FROM client_test_db.t1");
+ DIE_UNLESS(rc);
+ DIE_UNLESS(mysql_errno(mysql) == 1142);
+
+ result= mysql_list_fields(mysql, "../client_test_db/t1", NULL);
+ DIE_IF(result);
+
+ rc= mysql_change_user(mysql, opt_user, opt_password, current_db);
+ myquery(rc);
+ rc= mysql_query(mysql, "DROP TABLE t1");
+ myquery(rc);
+ rc= mysql_query(mysql, "DROP DATABASE bug53371");
+ myquery(rc);
+ rc= mysql_query(mysql, "DROP USER 'testbug'@localhost");
+ myquery(rc);
+}
+
+
/*
Read and parse arguments and MySQL options from my.cnf
*/
@@ -16982,6 +17023,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bug41078", test_bug41078 },
{ "test_bug20023", test_bug20023 },
{ "test_bug45010", test_bug45010 },
+ { "test_bug53371", test_bug53371 },
{ 0, 0 }
};