Skip to content

Commit 83bd8eb

Browse files
committed
Merge tag 'mariadb-10.1.47' into 10.1
2 parents 1a85022 + f4c85ef commit 83bd8eb

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
@@ -1667,24 +1667,65 @@ static int sst_donate_other (const char* method,
16671667
return arg.err;
16681668
}
16691669

1670+
/* return true if character can be a part of a filename */
1671+
static bool filename_char(int const c)
1672+
{
1673+
return isalnum(c) || (c == '-') || (c == '_') || (c == '.');
1674+
}
1675+
1676+
/* return true if character can be a part of an address string */
1677+
static bool address_char(int const c)
1678+
{
1679+
return filename_char(c) ||
1680+
(c == ':') || (c == '[') || (c == ']') || (c == '/');
1681+
}
1682+
1683+
static bool check_request_str(const char* const str,
1684+
bool (*check) (int c))
1685+
{
1686+
for (size_t i(0); str[i] != '\0'; ++i)
1687+
{
1688+
if (!check(str[i]))
1689+
{
1690+
WSREP_WARN("Illegal character in state transfer request: %i (%c).",
1691+
str[i], str[i]);
1692+
return true;
1693+
}
1694+
}
1695+
1696+
return false;
1697+
}
1698+
16701699
wsrep_cb_status_t wsrep_sst_donate_cb (void* app_ctx, void* recv_ctx,
16711700
const void* msg, size_t msg_len,
16721701
const wsrep_gtid_t* current_gtid,
16731702
const char* state, size_t state_len,
16741703
bool bypass)
16751704
{
1676-
/* This will be reset when sync callback is called.
1677-
* Should we set wsrep_ready to FALSE here too? */
1678-
1679-
wsrep_config_state.set(WSREP_MEMBER_DONOR);
1680-
16811705
const char* method = (char*)msg;
16821706
size_t method_len = strlen (method);
1707+
1708+
if (check_request_str(method, filename_char))
1709+
{
1710+
WSREP_ERROR("Bad SST method name. SST canceled.");
1711+
return WSREP_CB_FAILURE;
1712+
}
1713+
16831714
const char* data = method + method_len + 1;
16841715

1716+
if (check_request_str(data, address_char))
1717+
{
1718+
WSREP_ERROR("Bad SST address string. SST canceled.");
1719+
return WSREP_CB_FAILURE;
1720+
}
1721+
16851722
char uuid_str[37];
16861723
wsrep_uuid_print (&current_gtid->uuid, uuid_str, sizeof(uuid_str));
16871724

1725+
/* This will be reset when sync callback is called.
1726+
* Should we set wsrep_ready to FALSE here too? */
1727+
wsrep_config_state.set(WSREP_MEMBER_DONOR);
1728+
16881729
wsp::env env(NULL);
16891730
if (env.error())
16901731
{

0 commit comments

Comments
 (0)