summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2020-10-07 18:17:56 +0200
committerSergei Golubchik <serg@mariadb.org>2020-10-07 18:17:56 +0200
commit83bd8ebfcd2dd3aca4b5e89f6de993749e59e8e2 (patch)
tree596367971f87392c24134395c88a83bd83cd5992
parent1a850225d38484ce68901756347e5197adc17a9c (diff)
parentf4c85ef5ed0b2977fd5db61b166fd59764394234 (diff)
downloadmariadb-git-83bd8ebfcd2dd3aca4b5e89f6de993749e59e8e2.tar.gz
Merge tag 'mariadb-10.1.47' into 10.1
-rw-r--r--sql/wsrep_sst.cc51
1 files changed, 46 insertions, 5 deletions
diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc
index af4e02b9e55..c9a88cc30c8 100644
--- a/sql/wsrep_sst.cc
+++ b/sql/wsrep_sst.cc
@@ -1667,24 +1667,65 @@ static int sst_donate_other (const char* method,
return arg.err;
}
+/* return true if character can be a part of a filename */
+static bool filename_char(int const c)
+{
+ return isalnum(c) || (c == '-') || (c == '_') || (c == '.');
+}
+
+/* return true if character can be a part of an address string */
+static bool address_char(int const c)
+{
+ return filename_char(c) ||
+ (c == ':') || (c == '[') || (c == ']') || (c == '/');
+}
+
+static bool check_request_str(const char* const str,
+ bool (*check) (int c))
+{
+ for (size_t i(0); str[i] != '\0'; ++i)
+ {
+ if (!check(str[i]))
+ {
+ WSREP_WARN("Illegal character in state transfer request: %i (%c).",
+ str[i], str[i]);
+ return true;
+ }
+ }
+
+ return false;
+}
+
wsrep_cb_status_t wsrep_sst_donate_cb (void* app_ctx, void* recv_ctx,
const void* msg, size_t msg_len,
const wsrep_gtid_t* current_gtid,
const char* state, size_t state_len,
bool bypass)
{
- /* This will be reset when sync callback is called.
- * Should we set wsrep_ready to FALSE here too? */
-
- wsrep_config_state.set(WSREP_MEMBER_DONOR);
-
const char* method = (char*)msg;
size_t method_len = strlen (method);
+
+ if (check_request_str(method, filename_char))
+ {
+ WSREP_ERROR("Bad SST method name. SST canceled.");
+ return WSREP_CB_FAILURE;
+ }
+
const char* data = method + method_len + 1;
+ if (check_request_str(data, address_char))
+ {
+ WSREP_ERROR("Bad SST address string. SST canceled.");
+ return WSREP_CB_FAILURE;
+ }
+
char uuid_str[37];
wsrep_uuid_print (&current_gtid->uuid, uuid_str, sizeof(uuid_str));
+ /* This will be reset when sync callback is called.
+ * Should we set wsrep_ready to FALSE here too? */
+ wsrep_config_state.set(WSREP_MEMBER_DONOR);
+
wsp::env env(NULL);
if (env.error())
{