diff options
author | Nirbhay Choubey <nirbhay@skysql.com> | 2014-07-09 11:04:28 -0400 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@skysql.com> | 2014-07-09 11:04:28 -0400 |
commit | 40bfd20180a392f0c2e56cc99fff9ab3bf3ef87f (patch) | |
tree | 87a341f119275a1592e8e1dc629392ea20e40303 /sql/wsrep_sst.cc | |
parent | 04db5aeb097a9733ba31015f09198aea04067ee4 (diff) | |
download | mariadb-git-40bfd20180a392f0c2e56cc99fff9ab3bf3ef87f.tar.gz |
MDEV#6411 - Setting set @@global_wsrep_sst_auth=NULL
causes crash
Fixed by properly handling the NULL values.
Diffstat (limited to 'sql/wsrep_sst.cc')
-rw-r--r-- | sql/wsrep_sst.cc | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index 1b57b63131c..be9efa86873 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -120,31 +120,44 @@ bool wsrep_sst_auth_check (sys_var *self, THD* thd, set_var* var) { return 0; } + static bool sst_auth_real_set (const char* value) { - const char* v = strdup (value); + const char* v= NULL; - if (v) - { - if (sst_auth_real) free (const_cast<char*>(sst_auth_real)); - sst_auth_real = v; + if (value) + { + v= my_strdup(value, MYF(0)); + } + else // its NULL + { + wsrep_sst_auth_free(); + return 0; + } - if (strlen(sst_auth_real)) - { - if (wsrep_sst_auth) - { - my_free ((void*)wsrep_sst_auth); - wsrep_sst_auth = my_strdup(WSREP_SST_AUTH_MASK, MYF(0)); - //strncpy (wsrep_sst_auth, WSREP_SST_AUTH_MASK, - // sizeof(wsrep_sst_auth) - 1); - } - else - wsrep_sst_auth = my_strdup (WSREP_SST_AUTH_MASK, MYF(0)); - } - return 0; + if (v) + { + // set sst_auth_real + if (sst_auth_real) { my_free((void *) sst_auth_real); } + sst_auth_real = v; + + // mask wsrep_sst_auth + if (strlen(sst_auth_real)) + { + if (wsrep_sst_auth) { my_free((void*) wsrep_sst_auth); } + wsrep_sst_auth= my_strdup(WSREP_SST_AUTH_MASK, MYF(0)); } + return 0; + } + return 1; +} - return 1; +void wsrep_sst_auth_free() +{ + if (wsrep_sst_auth) { my_free((void *) wsrep_sst_auth); } + if (sst_auth_real) { my_free((void *) sst_auth_real); } + wsrep_sst_auth= NULL; + sst_auth_real= NULL; } bool wsrep_sst_auth_update (sys_var *self, THD* thd, enum_var_type type) |