Skip to content

Commit b18921c

Browse files
committed
Merge tag 'mariadb-10.2.34' into 10.2
2 parents 4aec143 + a464917 commit b18921c

File tree

1 file changed

+46
-5
lines changed

1 file changed

+46
-5
lines changed

sql/wsrep_sst.cc

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,24 +1726,65 @@ static int sst_donate_other (const char* method,
17261726
return arg.err;
17271727
}
17281728

1729+
/* return true if character can be a part of a filename */
1730+
static bool filename_char(int const c)
1731+
{
1732+
return isalnum(c) || (c == '-') || (c == '_') || (c == '.');
1733+
}
1734+
1735+
/* return true if character can be a part of an address string */
1736+
static bool address_char(int const c)
1737+
{
1738+
return filename_char(c) ||
1739+
(c == ':') || (c == '[') || (c == ']') || (c == '/');
1740+
}
1741+
1742+
static bool check_request_str(const char* const str,
1743+
bool (*check) (int c))
1744+
{
1745+
for (size_t i(0); str[i] != '\0'; ++i)
1746+
{
1747+
if (!check(str[i]))
1748+
{
1749+
WSREP_WARN("Illegal character in state transfer request: %i (%c).",
1750+
str[i], str[i]);
1751+
return true;
1752+
}
1753+
}
1754+
1755+
return false;
1756+
}
1757+
17291758
wsrep_cb_status_t wsrep_sst_donate_cb (void* app_ctx, void* recv_ctx,
17301759
const void* msg, size_t msg_len,
17311760
const wsrep_gtid_t* current_gtid,
17321761
const char* state, size_t state_len,
17331762
bool bypass)
17341763
{
1735-
/* This will be reset when sync callback is called.
1736-
* Should we set wsrep_ready to FALSE here too? */
1737-
1738-
wsrep_config_state->set(WSREP_MEMBER_DONOR);
1739-
17401764
const char* method = (char*)msg;
17411765
size_t method_len = strlen (method);
1766+
1767+
if (check_request_str(method, filename_char))
1768+
{
1769+
WSREP_ERROR("Bad SST method name. SST canceled.");
1770+
return WSREP_CB_FAILURE;
1771+
}
1772+
17421773
const char* data = method + method_len + 1;
17431774

1775+
if (check_request_str(data, address_char))
1776+
{
1777+
WSREP_ERROR("Bad SST address string. SST canceled.");
1778+
return WSREP_CB_FAILURE;
1779+
}
1780+
17441781
char uuid_str[37];
17451782
wsrep_uuid_print (&current_gtid->uuid, uuid_str, sizeof(uuid_str));
17461783

1784+
/* This will be reset when sync callback is called.
1785+
* Should we set wsrep_ready to FALSE here too? */
1786+
wsrep_config_state->set(WSREP_MEMBER_DONOR);
1787+
17471788
wsp::env env(NULL);
17481789
if (env.error())
17491790
{

0 commit comments

Comments
 (0)