Commit 92eafe1a authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-5521 SET ROLE as prepared statement crashes the server

set_role::light_check() was incorrect
parent 03b428d2
PREPARE stmt FROM 'SET ROLE NONE';
#
# MDEV-5521 SET ROLE as prepared statement crashes the server
#
PREPARE stmt FROM 'SET ROLE NONE';
...@@ -855,9 +855,7 @@ int set_var_password::update(THD *thd) ...@@ -855,9 +855,7 @@ int set_var_password::update(THD *thd)
int set_var_role::check(THD *thd) int set_var_role::check(THD *thd)
{ {
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
ulonglong access; int status= acl_check_setrole(thd, role.str, &access);
int status= acl_check_setrole(thd, base.str, &access);
save_result.ulonglong_value= access;
return status; return status;
#else #else
return 0; return 0;
...@@ -867,7 +865,7 @@ int set_var_role::check(THD *thd) ...@@ -867,7 +865,7 @@ int set_var_role::check(THD *thd)
int set_var_role::update(THD *thd) int set_var_role::update(THD *thd)
{ {
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
return acl_setrole(thd, base.str, save_result.ulonglong_value); return acl_setrole(thd, role.str, access);
#else #else
return 0; return 0;
#endif #endif
......
...@@ -278,11 +278,12 @@ public: ...@@ -278,11 +278,12 @@ public:
/* For SET ROLE */ /* For SET ROLE */
class set_var_role: public set_var class set_var_role: public set_var_base
{ {
LEX_STRING role;
ulonglong access;
public: public:
set_var_role(LEX_STRING role_arg) : set_var_role(LEX_STRING role_arg) : role(role_arg) {}
set_var(OPT_SESSION, NULL, &role_arg, NULL){};
int check(THD *thd); int check(THD *thd);
int update(THD *thd); int update(THD *thd);
}; };
......
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