Skip to content

Commit

Permalink
MDEV-8609 Server crashes in is_invalid_role_name on reloading ACL wit…
Browse files Browse the repository at this point in the history
…h 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)
  • Loading branch information
vuvova committed Oct 22, 2015
1 parent 27328ca commit 956e92d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions mysql-test/suite/roles/create_and_drop_role.result
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ select user, host, is_role from user where user like 'test%';
user host is_role
create role '';
ERROR OP000: Invalid role specification ``.
create role ' ';
ERROR OP000: Invalid role specification ``.
create role 'foo ';
drop role foo;
create role r1;
drop user r1;
ERROR HY000: Operation DROP USER failed for 'r1'@'%'
Expand Down
8 changes: 8 additions & 0 deletions mysql-test/suite/roles/create_and_drop_role.test
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ connection default;
--error ER_INVALID_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>
#
Expand Down
6 changes: 4 additions & 2 deletions sql/sql_yacc.yy
Original file line number Diff line number Diff line change
Expand Up @@ -15170,6 +15170,9 @@ current_role:
grant_role:
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)
{
my_error(ER_INVALID_ROLE, MYF(0), "");
Expand All @@ -15184,8 +15187,7 @@ grant_role:
$$->auth= empty_lex_str;

if (check_string_char_length(&$$->user, ER(ER_USERNAME),
username_char_length,
system_charset_info, 0))
username_char_length, cs, 0))
MYSQL_YYABORT;
}
| current_role
Expand Down

0 comments on commit 956e92d

Please sign in to comment.