mirror of
https://github.com/MariaDB/server.git
synced 2025-08-09 22:24:09 +03:00
MDEV-11533: Roles with trailing white spaces are not cleared correctly
Role names with trailing whitespaces are truncated in length as of
956e92d908
to fix MDEV-8609. The problem
is that the code that creates role mappings expects the string to be null
terminated.
Add the null terminator to account for that as well. In the future
the rest of the code can be cleaned up to never assume c style strings
but only LEX_STRINGS.
This commit is contained in:
@@ -68,3 +68,19 @@ GRANT USAGE ON *.* TO 'r1'@'localhost'
|
||||
DROP USER u1;
|
||||
DROP ROLE r2;
|
||||
DROP USER r1@localhost;
|
||||
create role 'foo ';
|
||||
select concat(user, '__'), is_role from mysql.user where user like 'foo%';
|
||||
concat(user, '__') is_role
|
||||
foo__ Y
|
||||
select * from mysql.roles_mapping;
|
||||
Host User Role Admin_option
|
||||
localhost root foo Y
|
||||
drop role foo;
|
||||
select concat(user, '__'), is_role from mysql.user where user like 'foo%';
|
||||
concat(user, '__') is_role
|
||||
select * from mysql.roles_mapping;
|
||||
Host User Role Admin_option
|
||||
show grants;
|
||||
Grants for root@localhost
|
||||
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
|
||||
GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION
|
||||
|
@@ -95,3 +95,15 @@ SHOW GRANTS FOR r1@localhost; # Related to MDEV-7774, also caused a crash, by
|
||||
DROP USER u1;
|
||||
DROP ROLE r2;
|
||||
DROP USER r1@localhost;
|
||||
|
||||
#
|
||||
# MDEV-11533: Roles with trailing white spaces are not cleared correctly
|
||||
#
|
||||
create role 'foo ';
|
||||
select concat(user, '__'), is_role from mysql.user where user like 'foo%';
|
||||
select * from mysql.roles_mapping;
|
||||
drop role foo;
|
||||
select concat(user, '__'), is_role from mysql.user where user like 'foo%';
|
||||
select * from mysql.roles_mapping;
|
||||
--sorted_result
|
||||
show grants;
|
||||
|
@@ -15178,6 +15178,7 @@ grant_role:
|
||||
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);
|
||||
$1.str[$1.length] = '\0';
|
||||
if ($1.length == 0)
|
||||
{
|
||||
my_error(ER_INVALID_ROLE, MYF(0), "");
|
||||
|
Reference in New Issue
Block a user