1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-5225 Server crashes on CREATE USER|ROLE CURRENT_ROLE or DROP ROLE CURRENT_ROLE

This commit is contained in:
Sergei Golubchik
2013-11-02 16:26:01 +01:00
parent f4d5d849fd
commit 1f0368658b
3 changed files with 121 additions and 1 deletions

View File

@ -9043,6 +9043,13 @@ static void append_user(String *str, LEX_USER *user)
str->append('\'');
}
static void append_str(String *str, const char *s, size_t l)
{
if (str->length())
str->append(',');
str->append(s, l);
}
/*
Create a list of users.
@ -9080,6 +9087,20 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list, bool handle_as_role)
while ((user_name= user_list++))
{
if (user_name->user.str == current_user.str)
{
append_str(&wrong_users, STRING_WITH_LEN("CURRENT_USER"));
result= TRUE;
continue;
}
if (user_name->user.str == current_role.str)
{
append_str(&wrong_users, STRING_WITH_LEN("CURRENT_ROLE"));
result= TRUE;
continue;
}
if (handle_as_role && is_invalid_role_name(user_name->user.str))
{
append_user(&wrong_users, user_name);
@ -9189,7 +9210,15 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list, bool handle_as_role)
while ((tmp_user_name= user_list++))
{
user_name= get_current_user(thd, tmp_user_name, false);
if (!user_name || handle_as_role != user_name->is_role())
if (!user_name)
{
thd->clear_error();
append_str(&wrong_users, STRING_WITH_LEN("CURRENT_ROLE"));
result= TRUE;
continue;
}
if (handle_as_role != user_name->is_role())
{
append_user(&wrong_users, tmp_user_name);
result= TRUE;