diff options
author | Sergei Golubchik <serg@mariadb.org> | 2015-10-22 11:58:54 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2015-10-22 11:58:54 +0200 |
commit | 956e92d90873532fee95581c702f7b76643969ea (patch) | |
tree | faf0e7021947d6b333be6b05faa7c5a5448230dd | |
parent | 27328ca1f43e252ed32712210cac1a83d5a0c96d (diff) | |
download | mariadb-git-956e92d90873532fee95581c702f7b76643969ea.tar.gz |
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)
-rw-r--r-- | mysql-test/suite/roles/create_and_drop_role.result | 4 | ||||
-rw-r--r-- | mysql-test/suite/roles/create_and_drop_role.test | 8 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 6 |
3 files changed, 16 insertions, 2 deletions
diff --git a/mysql-test/suite/roles/create_and_drop_role.result b/mysql-test/suite/roles/create_and_drop_role.result index 79c6f412111..d565b888c5f 100644 --- a/mysql-test/suite/roles/create_and_drop_role.result +++ b/mysql-test/suite/roles/create_and_drop_role.result @@ -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'@'%' diff --git a/mysql-test/suite/roles/create_and_drop_role.test b/mysql-test/suite/roles/create_and_drop_role.test index 0bf5b744e6b..71d6de7053f 100644 --- a/mysql-test/suite/roles/create_and_drop_role.test +++ b/mysql-test/suite/roles/create_and_drop_role.test @@ -53,6 +53,14 @@ connection default; 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> # create role r1; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index bb8215aaaec..4225f7317b8 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -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), ""); @@ -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 |