@@ -1667,24 +1667,65 @@ static int sst_donate_other (const char* method,
1667
1667
return arg.err ;
1668
1668
}
1669
1669
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
+
1670
1699
wsrep_cb_status_t wsrep_sst_donate_cb (void * app_ctx, void * recv_ctx,
1671
1700
const void * msg, size_t msg_len,
1672
1701
const wsrep_gtid_t * current_gtid,
1673
1702
const char * state, size_t state_len,
1674
1703
bool bypass)
1675
1704
{
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
-
1681
1705
const char * method = (char *)msg;
1682
1706
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
+
1683
1714
const char * data = method + method_len + 1 ;
1684
1715
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
+
1685
1722
char uuid_str[37 ];
1686
1723
wsrep_uuid_print (¤t_gtid->uuid , uuid_str, sizeof (uuid_str));
1687
1724
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
+
1688
1729
wsp::env env (NULL );
1689
1730
if (env.error ())
1690
1731
{
0 commit comments