@@ -1726,24 +1726,65 @@ static int sst_donate_other (const char* method,
1726
1726
return arg.err ;
1727
1727
}
1728
1728
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
+
1729
1758
wsrep_cb_status_t wsrep_sst_donate_cb (void * app_ctx, void * recv_ctx,
1730
1759
const void * msg, size_t msg_len,
1731
1760
const wsrep_gtid_t * current_gtid,
1732
1761
const char * state, size_t state_len,
1733
1762
bool bypass)
1734
1763
{
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
-
1740
1764
const char * method = (char *)msg;
1741
1765
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
+
1742
1773
const char * data = method + method_len + 1 ;
1743
1774
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
+
1744
1781
char uuid_str[37 ];
1745
1782
wsrep_uuid_print (¤t_gtid->uuid , uuid_str, sizeof (uuid_str));
1746
1783
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
+
1747
1788
wsp::env env (NULL );
1748
1789
if (env.error ())
1749
1790
{
0 commit comments