diff options
| author | Sergei Golubchik <sergii@pisem.net> | 2014-03-15 18:24:15 +0100 |
|---|---|---|
| committer | Sergei Golubchik <sergii@pisem.net> | 2014-03-15 18:24:15 +0100 |
| commit | d7304375e5e0ce30979c2b92e70eb0effaa30a25 (patch) | |
| tree | bb9d05f40e948d4b027f4da9c007c433a16fa1a6 /sql/sql_parse.cc | |
| parent | cd29dc98216d822ad701d604b3eda886e1db2aaa (diff) | |
| parent | e0f3a0fae98bea144b962ef8dbbe62e0935aebb1 (diff) | |
| download | mariadb-git-d7304375e5e0ce30979c2b92e70eb0effaa30a25.tar.gz | |
mysql-5.1.73 merge
Diffstat (limited to 'sql/sql_parse.cc')
| -rw-r--r-- | sql/sql_parse.cc | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e0e6a4a57d6..b8e2db67ed9 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1,6 +1,6 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. - Copyright (c) 2008-2011 Monty Program Ab + Copyright (c) 2000, 2013, Oracle and/or its affiliates. + Copyright (c) 2008, 2014, Monty Program Ab. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1124,6 +1124,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, char *user= (char*) packet, *packet_end= packet + packet_length; /* Safe because there is always a trailing \0 at the end of the packet */ char *passwd= strend(user)+1; + uint user_length= passwd - user - 1; thd->change_user(); thd->clear_error(); // if errors from rollback @@ -1137,6 +1138,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, for *passwd > 127 and become 2**32-127 after casting to uint. */ char db_buff[SAFE_NAME_LEN+1]; // buffer to store db in utf8 + char user_buff[USERNAME_LENGTH + 1]; // buffer to store user in utf8 char *db= passwd; char *save_db; /* @@ -1187,15 +1189,31 @@ bool dispatch_command(enum enum_server_command command, THD *thd, my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "character_set_client", cs->csname); break; - } + } + + if (cs_number) + { + /* + We have checked charset earlier, + so thd_init_client_charset cannot fail. + */ + if (thd_init_client_charset(thd, cs_number)) + DBUG_ASSERT(0); + thd->update_charset(); + } } - /* Convert database name to utf8 */ + /* Convert database and user names to utf8 */ db_buff[copy_and_convert(db_buff, sizeof(db_buff)-1, system_charset_info, db, db_length, thd->charset(), &dummy_errors)]= 0; db= db_buff; + user_buff[copy_and_convert(user_buff,sizeof(user_buff)-1, + system_charset_info, user, user_length, + thd->charset(), &dummy_errors)]= 0; + user= user_buff; + /* Save user and privileges */ save_db_length= thd->db_length; save_db= thd->db; @@ -1228,19 +1246,10 @@ bool dispatch_command(enum enum_server_command command, THD *thd, if (save_user_connect) decrease_user_connections(save_user_connect); #endif /* NO_EMBEDDED_ACCESS_CHECKS */ + pthread_mutex_lock(&thd->LOCK_thd_data); x_free(save_db); + pthread_mutex_unlock(&thd->LOCK_thd_data); x_free(save_security_ctx.user); - - if (cs_number) - { - /* - We have checked charset earlier, - so thd_init_client_charset cannot fail. - */ - if (thd_init_client_charset(thd, cs_number)) - DBUG_ASSERT(0); - thd->update_charset(); - } } break; } |
