diff options
author | unknown <msvensson@shellback.(none)> | 2006-04-18 10:46:17 +0200 |
---|---|---|
committer | unknown <msvensson@shellback.(none)> | 2006-04-18 10:46:17 +0200 |
commit | 3bcbf91376ff05ee9da1736c98998356c3bcbc56 (patch) | |
tree | b5c897a1916d22ac7c068c451037aa4300b77c41 /sql | |
parent | d33fc7bad1a7e019434692d5244f6477373771f3 (diff) | |
download | mariadb-git-3bcbf91376ff05ee9da1736c98998356c3bcbc56.tar.gz |
BUG#13310 incorrect user parsing by SP
- Strip surrounding ''s from username when a new user connects. There
is no user 'a@', it should be a@
mysql-test/r/grant2.result:
Update test result
mysql-test/t/grant2.test:
Add tests for bug 13310
sql/sql_parse.cc:
Strip surrounding ''s from username when a new user connects. There
is no user 'a@', it should be a@
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_parse.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index d9f5499f362..e163a7a1093 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -993,6 +993,7 @@ static int check_connection(THD *thd) char *user= end; char *passwd= strend(user)+1; + uint user_len= passwd - user - 1; char *db= passwd; char db_buff[NAME_LEN+1]; // buffer to store db in utf8 char user_buff[USERNAME_LENGTH+1]; // buffer to store user in utf8 @@ -1018,11 +1019,19 @@ static int check_connection(THD *thd) db= db_buff; } - user_buff[copy_and_convert(user_buff, sizeof(user_buff)-1, - system_charset_info, user, strlen(user), - thd->charset(), &dummy_errors)]= '\0'; + user_buff[user_len= copy_and_convert(user_buff, sizeof(user_buff)-1, + system_charset_info, user, user_len, + thd->charset(), &dummy_errors)]= '\0'; user= user_buff; + /* If username starts and ends in "'", chop them off */ + if (user_len > 1 && user[0] == '\'' && user[user_len - 1] == '\'') + { + user[user_len-1]= 0; + user++; + user_len-= 2; + } + if (thd->main_security_ctx.user) x_free(thd->main_security_ctx.user); if (!(thd->main_security_ctx.user= my_strdup(user, MYF(0)))) |