Skip to content

Commit

Permalink
MDEV-24856 : Server crashes when wsrep_provider_options set to NULL
Browse files Browse the repository at this point in the history
Null pointer reference to wsrep_provider_options variable. Fixed
by adding condition and error handling.
  • Loading branch information
Jan Lindström committed Feb 13, 2021
1 parent 542d769 commit cb4434c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
10 changes: 10 additions & 0 deletions mysql-test/suite/galera/r/galera_var_wsrep_provider_options.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
connection node_2;
connection node_1;
call mtr.add_suppression("WSREP: Unknown parameter 'a'");
call mtr.add_suppression("WSREP: Set options returned 7");
SET GLOBAL wsrep_provider_options=NULL;
ERROR HY000: Incorrect arguments to SET
SET GLOBAL wsrep_provider_options='';
SET GLOBAL wsrep_provider_options=' ';
SET GLOBAL wsrep_provider_options='a=1';
ERROR HY000: Incorrect arguments to SET
11 changes: 11 additions & 0 deletions mysql-test/suite/galera/t/galera_var_wsrep_provider_options.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--source include/galera_cluster.inc

call mtr.add_suppression("WSREP: Unknown parameter 'a'");
call mtr.add_suppression("WSREP: Set options returned 7");

--error ER_WRONG_ARGUMENTS
SET GLOBAL wsrep_provider_options=NULL;
SET GLOBAL wsrep_provider_options='';
SET GLOBAL wsrep_provider_options=' ';
--error ER_WRONG_ARGUMENTS
SET GLOBAL wsrep_provider_options='a=1';
20 changes: 13 additions & 7 deletions sql/wsrep_var.cc
Original file line number Diff line number Diff line change
Expand Up @@ -457,15 +457,21 @@ bool wsrep_provider_options_check(sys_var *self, THD* thd, set_var* var)

bool wsrep_provider_options_update(sys_var *self, THD* thd, enum_var_type type)
{
enum wsrep::provider::status ret=
Wsrep_server_state::instance().provider().options(wsrep_provider_options);
if (ret)
if (wsrep_provider_options)
{
WSREP_ERROR("Set options returned %d", ret);
refresh_provider_options();
return true;
enum wsrep::provider::status ret=
Wsrep_server_state::instance().provider().options(wsrep_provider_options);
if (ret)
{
WSREP_ERROR("Set options returned %d", ret);
goto err;
}

return refresh_provider_options();
}
return refresh_provider_options();
err:
refresh_provider_options();
return true;
}

void wsrep_provider_options_init(const char* value)
Expand Down

0 comments on commit cb4434c

Please sign in to comment.