Commit 956e92d9 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-8609 Server crashes in is_invalid_role_name on reloading ACL with a blank role name

strip endspaces from the role name in the parser
because they'll be lost anyway when the name is stored
in the mysql.user.user column (of type CHAR)
parent 27328ca1
...@@ -36,6 +36,10 @@ select user, host, is_role from user where user like 'test%'; ...@@ -36,6 +36,10 @@ select user, host, is_role from user where user like 'test%';
user host is_role user host is_role
create role ''; create role '';
ERROR OP000: Invalid role specification ``. ERROR OP000: Invalid role specification ``.
create role ' ';
ERROR OP000: Invalid role specification ``.
create role 'foo ';
drop role foo;
create role r1; create role r1;
drop user r1; drop user r1;
ERROR HY000: Operation DROP USER failed for 'r1'@'%' ERROR HY000: Operation DROP USER failed for 'r1'@'%'
......
...@@ -52,6 +52,14 @@ connection default; ...@@ -52,6 +52,14 @@ connection default;
--error ER_INVALID_ROLE --error ER_INVALID_ROLE
create role ''; create role '';
#
# MDEV-8609 Server crashes in is_invalid_role_name on reloading ACL with a blank role name
#
--error ER_INVALID_ROLE
create role ' ';
create role 'foo ';
drop role foo;
# #
# MDEV-5523 Server crashes on DROP USER <rolename> # MDEV-5523 Server crashes on DROP USER <rolename>
# #
......
...@@ -15170,6 +15170,9 @@ current_role: ...@@ -15170,6 +15170,9 @@ current_role:
grant_role: grant_role:
ident_or_text ident_or_text
{ {
CHARSET_INFO *cs= system_charset_info;
/* trim end spaces (as they'll be lost in mysql.user anyway) */
$1.length= cs->cset->lengthsp(cs, $1.str, $1.length);
if ($1.length == 0) if ($1.length == 0)
{ {
my_error(ER_INVALID_ROLE, MYF(0), ""); my_error(ER_INVALID_ROLE, MYF(0), "");
...@@ -15184,8 +15187,7 @@ grant_role: ...@@ -15184,8 +15187,7 @@ grant_role:
$$->auth= empty_lex_str; $$->auth= empty_lex_str;
if (check_string_char_length(&$$->user, ER(ER_USERNAME), if (check_string_char_length(&$$->user, ER(ER_USERNAME),
username_char_length, username_char_length, cs, 0))
system_charset_info, 0))
MYSQL_YYABORT; MYSQL_YYABORT;
} }
| current_role | current_role
......
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