@@ -1822,6 +1822,35 @@ static int sst_donate_other (const char* method,
1822
1822
return arg.err ;
1823
1823
}
1824
1824
1825
+ /* return true if character can be a part of a filename */
1826
+ static bool filename_char (int const c)
1827
+ {
1828
+ return isalnum (c) || (c == ' -' ) || (c == ' _' ) || (c == ' .' );
1829
+ }
1830
+
1831
+ /* return true if character can be a part of an address string */
1832
+ static bool address_char (int const c)
1833
+ {
1834
+ return filename_char (c) ||
1835
+ (c == ' :' ) || (c == ' [' ) || (c == ' ]' ) || (c == ' /' );
1836
+ }
1837
+
1838
+ static bool check_request_str (const char * const str,
1839
+ bool (*check) (int c))
1840
+ {
1841
+ for (size_t i (0 ); str[i] != ' \0 ' ; ++i)
1842
+ {
1843
+ if (!check (str[i]))
1844
+ {
1845
+ WSREP_WARN (" Illegal character in state transfer request: %i (%c)." ,
1846
+ str[i], str[i]);
1847
+ return true ;
1848
+ }
1849
+ }
1850
+
1851
+ return false ;
1852
+ }
1853
+
1825
1854
int wsrep_sst_donate (const std::string& msg,
1826
1855
const wsrep::gtid& current_gtid,
1827
1856
const bool bypass)
@@ -1833,8 +1862,21 @@ int wsrep_sst_donate(const std::string& msg,
1833
1862
1834
1863
const char * method= msg.data ();
1835
1864
size_t method_len= strlen (method);
1865
+
1866
+ if (check_request_str (method, filename_char))
1867
+ {
1868
+ WSREP_ERROR (" Bad SST method name. SST canceled." );
1869
+ return WSREP_CB_FAILURE;
1870
+ }
1871
+
1836
1872
const char * data= method + method_len + 1 ;
1837
1873
1874
+ if (check_request_str (data, address_char))
1875
+ {
1876
+ WSREP_ERROR (" Bad SST address string. SST canceled." );
1877
+ return WSREP_CB_FAILURE;
1878
+ }
1879
+
1838
1880
wsp::env env (NULL );
1839
1881
if (env.error ())
1840
1882
{
0 commit comments