summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorunknown <monty@donna.mysql.com>2001-01-31 04:47:25 +0200
committerunknown <monty@donna.mysql.com>2001-01-31 04:47:25 +0200
commit495231ea25a82d97e69e96ff9e5d7688434cfff2 (patch)
tree851a8ba92ed9883efe2504e0726aae6843c317c0 /sql/sql_parse.cc
parentbf1f8fd3eb4b98dadd265f8ed10d92220dabe1bb (diff)
downloadmariadb-git-495231ea25a82d97e69e96ff9e5d7688434cfff2.tar.gz
New myisamchk option --sort-recover
Allow delete of crashed MyISAM tables Fixed bug when BLOB was first part of key Fixed bug when using result from CASE in GROUP BY Fixed core-dump bug in monthname() Optimized calling of check_db_name() Docs/manual.texi: Added more information about myisamchk client/mysqladmin.c: Added error message for CREATE database and fixed possible overflow bug include/myisam.h: New myisamchk option --sort-recover libmysql/libmysql.c: Removed commented code Don't define getpwuid (breaks on SCO 3.2) myisam/mi_check.c: Fixed (new) bug when using --recover --optimize myisam/mi_delete_table.c: Allow delete of crashed tables myisam/mi_key.c: Fixed bug when BLOB was first part of key myisam/myisamchk.c: New myisamchk option --sort-recover mysql-test/r/case.result: New test cases to check for reported bugs mysql-test/r/func_time.result: New test cases to check for reported bugs mysql-test/r/type_blob.result: New test cases to check for reported bugs mysql-test/r/type_datetime.result: New test cases to check for reported bugs mysql-test/t/case.test: New test cases to check for reported bugs mysql-test/t/func_time.test: New test cases to check for reported bugs mysql-test/t/type_blob.test: New test cases to check for reported bugs mysql-test/t/type_datetime.test: New test cases to check for reported bugs mysys/my_bitmap.c: Optimize sql-bench/limits/ms-sql.cfg: Updated limits sql/item_cmpfunc.cc: Fixed bug when using result from CASE in GROUP BY sql/item_cmpfunc.h: Fixed bug when using result from CASE in GROUP BY sql/item_timefunc.cc: Fixed core-dump bug in monthname() sql/sql_db.cc: Optimized calling of check_db_name() sql/sql_parse.cc: Optimized calling of check_db_name() sql/table.cc: Fixed typo
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc50
1 files changed, 36 insertions, 14 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 2926f59547f..854a47fd9c0 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -510,7 +510,7 @@ int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd)
int error = 0;
DBUG_ENTER("mysql_table_dump");
db = (db && db[0]) ? db : thd->db;
- if(!(table_list = (TABLE_LIST*) sql_calloc(sizeof(TABLE_LIST))))
+ if (!(table_list = (TABLE_LIST*) sql_calloc(sizeof(TABLE_LIST))))
DBUG_RETURN(1); // out of memory
table_list->db = db;
table_list->real_name = table_list->name = tbl_name;
@@ -518,9 +518,14 @@ int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd)
table_list->next = 0;
remove_escape(table_list->real_name);
- if(!(table=open_ltable(thd, table_list, TL_READ_NO_INSERT)))
+ if (!(table=open_ltable(thd, table_list, TL_READ_NO_INSERT)))
DBUG_RETURN(1);
+ if (!db || check_db_name(db))
+ {
+ net_printf(&thd->net,ER_WRONG_DB_NAME, db ? db : "NULL");
+ goto err;
+ }
if (check_access(thd, SELECT_ACL, db, &table_list->grant.privilege))
goto err;
if (grant_option && check_grant(thd, SELECT_ACL, table_list))
@@ -710,6 +715,12 @@ bool do_command(THD *thd)
case COM_CREATE_DB:
{
char *db=thd->strdup(packet+1);
+ // null test to handle EOM
+ if (!db || !stripp_sp(db) || check_db_name(db))
+ {
+ net_printf(&thd->net,ER_WRONG_DB_NAME, db ? db : "NULL");
+ break;
+ }
if (check_access(thd,CREATE_ACL,db,0,1))
break;
mysql_log.write(thd,command,packet+1);
@@ -719,6 +730,12 @@ bool do_command(THD *thd)
case COM_DROP_DB:
{
char *db=thd->strdup(packet+1);
+ // null test to handle EOM
+ if (!db || !stripp_sp(db) || check_db_name(db))
+ {
+ net_printf(&thd->net,ER_WRONG_DB_NAME, db ? db : "NULL");
+ break;
+ }
if (check_access(thd,DROP_ACL,db,0,1) || end_active_trans(thd))
break;
mysql_log.write(thd,command,db);
@@ -1503,10 +1520,10 @@ mysql_execute_command(void)
goto error; /* purecov: inspected */
}
remove_escape(db); // Fix escaped '_'
- if (strlen(db) > NAME_LEN)
+ if (check_db_name(db))
{
- net_printf(&thd->net,ER_WRONG_DB_NAME, db);
- goto error;
+ net_printf(&thd->net,ER_WRONG_DB_NAME, db);
+ goto error;
}
if (check_access(thd,SELECT_ACL,db,&thd->col_access))
goto error; /* purecov: inspected */
@@ -1666,6 +1683,11 @@ mysql_execute_command(void)
break;
case SQLCOM_CREATE_DB:
{
+ if (!stripp_sp(lex->name) || check_db_name(lex->name))
+ {
+ net_printf(&thd->net,ER_WRONG_DB_NAME, lex->name);
+ break;
+ }
if (check_access(thd,CREATE_ACL,lex->name,0,1))
break;
mysql_create_db(thd,lex->name,lex->create_info.options);
@@ -1673,6 +1695,11 @@ mysql_execute_command(void)
}
case SQLCOM_DROP_DB:
{
+ if (!stripp_sp(lex->name) || check_db_name(lex->name))
+ {
+ net_printf(&thd->net,ER_WRONG_DB_NAME, lex->name);
+ break;
+ }
if (check_access(thd,DROP_ACL,lex->name,0,1) ||
end_active_trans(thd))
break;
@@ -1887,12 +1914,6 @@ check_access(THD *thd,uint want_access,const char *db, uint *save_priv,
if (db == any_db)
return FALSE; // Allow select on anything
- if (strlen(db) > NAME_LEN || check_db_name(db))
- {
- net_printf(&thd->net,ER_WRONG_DB_NAME, db);
- return TRUE;
- }
-
if (db && (!thd->db || strcmp(db,thd->db)))
db_access=acl_get(thd->host, thd->ip, (char*) &thd->remote.sin_addr,
thd->priv_user, db); /* purecov: inspected */
@@ -1970,7 +1991,8 @@ static bool check_db_used(THD *thd,TABLE_LIST *tables)
}
-static bool check_merge_table_access(THD *thd, char *db, TABLE_LIST *table_list)
+static bool check_merge_table_access(THD *thd, char *db,
+ TABLE_LIST *table_list)
{
int error=0;
if (table_list)
@@ -2463,8 +2485,8 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias,
DBUG_RETURN(0); // End of memory
alias_str= alias ? alias->str : table->table.str;
if (table->table.length > NAME_LEN ||
- table->db.str && table->db.length > NAME_LEN ||
- check_table_name(table->table.str,table->table.length))
+ check_table_name(table->table.str,table->table.length) ||
+ table->db.str && check_db_name(table->db.str))
{
net_printf(&thd->net,ER_WRONG_TABLE_NAME,table->table.str);
DBUG_RETURN(0);