Commit b56f1d82 authored by Tatiana A. Nurnberg's avatar Tatiana A. Nurnberg

Bug #49752: 2469.126.2 unintentionally breaks authentication against

                  MySQL 5.1 server

Server used to clip overly long user-names. This was presumably lost
when code was made UTF8-clean.

Now we emulate the behaviour for backward compatibility, but UTF8-ly
correct.
parent d47e8991
...@@ -215,6 +215,17 @@ SET GLOBAL event_scheduler = OFF; ...@@ -215,6 +215,17 @@ SET GLOBAL event_scheduler = OFF;
# -- End of Bug#35074. # -- End of Bug#35074.
#
# -- Bug#49752: 2469.126.2 unintentionally breaks authentication
# against MySQL 5.1 server
#
GRANT ALL ON test.* TO 'Azundris12345678'@'localhost' IDENTIFIED BY 'test123';
FLUSH PRIVILEGES;
DROP USER 'Azundris12345678'@'localhost';
FLUSH PRIVILEGES;
#
# -- End of Bug#49752
#
# ------------------------------------------------------------------ # ------------------------------------------------------------------
# -- End of 5.1 tests # -- End of 5.1 tests
# ------------------------------------------------------------------ # ------------------------------------------------------------------
...@@ -293,6 +293,34 @@ SET GLOBAL event_scheduler = OFF; ...@@ -293,6 +293,34 @@ SET GLOBAL event_scheduler = OFF;
--echo # -- End of Bug#35074. --echo # -- End of Bug#35074.
--echo --echo
###########################################################################
--echo #
--echo # -- Bug#49752: 2469.126.2 unintentionally breaks authentication
--echo # against MySQL 5.1 server
--echo #
GRANT ALL ON test.* TO 'Azundris12345678'@'localhost' IDENTIFIED BY 'test123';
FLUSH PRIVILEGES;
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
connect (con1,localhost,Azundris123456789,test123,test);
disconnect con1;
connection default;
DROP USER 'Azundris12345678'@'localhost';
FLUSH PRIVILEGES;
--echo #
--echo # -- End of Bug#49752
--echo #
--echo # ------------------------------------------------------------------ --echo # ------------------------------------------------------------------
--echo # -- End of 5.1 tests --echo # -- End of 5.1 tests
--echo # ------------------------------------------------------------------ --echo # ------------------------------------------------------------------
......
...@@ -899,6 +899,19 @@ static int check_connection(THD *thd) ...@@ -899,6 +899,19 @@ static int check_connection(THD *thd)
user_len-= 2; user_len-= 2;
} }
/*
Clip username to allowed length in characters (not bytes). This is
mostly for backward compatibility.
*/
{
CHARSET_INFO *cs= system_charset_info;
int err;
user_len= (uint) cs->cset->well_formed_len(cs, user, user + user_len,
USERNAME_CHAR_LENGTH, &err);
user[user_len]= '\0';
}
if (thd->main_security_ctx.user) if (thd->main_security_ctx.user)
x_free(thd->main_security_ctx.user); x_free(thd->main_security_ctx.user);
if (!(thd->main_security_ctx.user= my_strdup(user, MYF(MY_WME)))) if (!(thd->main_security_ctx.user= my_strdup(user, MYF(MY_WME))))
......
...@@ -208,14 +208,11 @@ charpos() - calculates the offset of the given position in the string. ...@@ -208,14 +208,11 @@ charpos() - calculates the offset of the given position in the string.
Used in SQL functions LEFT(), RIGHT(), SUBSTRING(), Used in SQL functions LEFT(), RIGHT(), SUBSTRING(),
INSERT() INSERT()
well_formed_length() well_formed_len()
- finds the length of correctly formed multi-byte beginning. - returns length of a given multi-byte string in bytes
Used in INSERTs to cut a beginning of the given string Used in INSERTs to shorten the given string so it
which is a) is "well formed" according to the given character set
a) "well formed" according to the given character set.
b) can fit into the given data type b) can fit into the given data type
Terminates the string in the good position, taking in account
multi-byte character boundaries.
lengthsp() - returns the length of the given string without trailing spaces. lengthsp() - returns the length of the given string without trailing spaces.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment