fix the use of strchrnul() which may be not available on some systems

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
This commit is contained in:
Alexey Yurchenko 2024-05-17 23:42:16 +03:00 committed by Julius Goryavsky
parent 2ba1a8b878
commit 29e9ade269

View file

@ -1142,6 +1142,13 @@ static void copy_orig_argv (char* cmd_str)
}
}
/* implementation of strchrnul for systems that don't have it */
static const char* sst_strchrnul(const char* s, int c)
{
const char* ret= strchr(s, c);
return ret ? ret : s + strlen(s);
}
static ssize_t sst_prepare_other (const char* method,
const char* addr_in,
const char** addr_out)
@ -1209,7 +1216,7 @@ static ssize_t sst_prepare_other (const char* method,
sst_auth auth;
if (sst_auth_real)
{
const char* col= strchrnul(sst_auth_real, ':');
const char* col= sst_strchrnul(sst_auth_real, ':');
auth.name_ = std::string(sst_auth_real, col - sst_auth_real);
auth.pswd_ = std::string(':' == *col ? col + 1 : "");
}
@ -2331,7 +2338,7 @@ int wsrep_sst_donate(const std::string& msg,
if (sst_auth_real)
{
/* User supplied non-trivial wsre_sst_auth, use it */
const char* col= strchrnul(sst_auth_real, ':');
const char* col= sst_strchrnul(sst_auth_real, ':');
auth.name_ = std::string(sst_auth_real, col - sst_auth_real);
auth.pswd_ = std::string(':' == *col ? col + 1 : "");
}
@ -2350,7 +2357,7 @@ int wsrep_sst_donate(const std::string& msg,
{
/* wsp::string is just a dynamically allocated char* underneath
* so we can safely do all that arithmetics */
const char* col= strchrnul(remote_auth(), ':');
const char* col= sst_strchrnul(remote_auth(), ':');
auth.remote_name_ = std::string(remote_auth(), col - remote_auth());
auth.remote_pswd_ = std::string(':' == *col ? col + 1 : "");
}