Commit b4496129 authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru

MDEV-8638: REVOKE ALL PRIVILEGES, GRANT OPTION FROM CURRENT_ROLE breaks replication

Fix the replication failure caused by incorect initialization of
THD::invoker_host && THD::invoker_user.

Breakdown of the failure is this:
Query_log_event::host and Query_log_event::user can have their
LEX_STRING's set to length 0, but the actual str member points to
garbage. Code afterwards copies Query_log_event::host and user to
THD::invoker_host and THD::invoker_user.

Calling code for these members expects both members to be initialized.
Eg. the str member be a NULL terminated string and length have
appropriate size.
parent 5fd80875
include/master-slave.inc
[connection master]
create role r1;
set role r1;
grant select on db.* to current_role;
revoke all privileges, grant option from current_role;
drop role r1;
include/rpl_end.inc
connection server_2;
connection server_2;
connection server_2;
connection server_2;
connection server_1;
connection server_1;
connection server_1;
connection server_2;
connection server_1;
connection server_2;
connection server_2;
connection server_1;
connection server_1;
--source include/master-slave.inc
--source include/have_binlog_format_mixed.inc
--enable_connect_log
create role r1;
set role r1;
grant select on db.* to current_role;
revoke all privileges, grant option from current_role;
drop role r1;
--source include/rpl_end.inc
......@@ -3631,10 +3631,25 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
if (time_zone_len)
copy_str_and_move(&time_zone_str, &start, time_zone_len);
if (user.length > 0)
if (user.length)
{
copy_str_and_move((const char **)&(user.str), &start, user.length);
if (host.length > 0)
}
else
{
user.str= (char *) start++;
user.str[0]= '\0';
}
if (host.length)
{
copy_str_and_move((const char **)&(host.str), &start, host.length);
}
else
{
host.str= (char *) start++;
host.str[0]= '\0';
}
/**
if time_zone_len or catalog_len are 0, then time_zone and catalog
......
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