File tree Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,8 @@ static const string CHARS_ALPHA_NUM = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO
19
19
static const string SAFE_CHARS[] =
20
20
{
21
21
CHARS_ALPHA_NUM + " .,;-_/:?@()" , // SAFE_CHARS_DEFAULT
22
- CHARS_ALPHA_NUM + " .,;-_?@" // SAFE_CHARS_UA_COMMENT
22
+ CHARS_ALPHA_NUM + " .,;-_?@" , // SAFE_CHARS_UA_COMMENT
23
+ CHARS_ALPHA_NUM + " .-_" , // SAFE_CHARS_FILENAME
23
24
};
24
25
25
26
string SanitizeString (const string& str, int rule)
Original file line number Diff line number Diff line change 26
26
enum SafeChars
27
27
{
28
28
SAFE_CHARS_DEFAULT, // !< The full set of allowed chars
29
- SAFE_CHARS_UA_COMMENT // !< BIP-0014 subset
29
+ SAFE_CHARS_UA_COMMENT, // !< BIP-0014 subset
30
+ SAFE_CHARS_FILENAME, // !< Chars allowed in filenames
30
31
};
31
32
32
33
/* *
Original file line number Diff line number Diff line change @@ -3765,6 +3765,12 @@ bool CWallet::InitLoadWallet()
3765
3765
3766
3766
std::string walletFile = GetArg (" -wallet" , DEFAULT_WALLET_DAT);
3767
3767
3768
+ if (walletFile.find_first_of (" /\\ " ) != std::string::npos) {
3769
+ return InitError (_ (" -wallet parameter must only specify a filename (not a path)" ));
3770
+ } else if (SanitizeString (walletFile, SAFE_CHARS_FILENAME) != walletFile) {
3771
+ return InitError (_ (" Invalid characters in -wallet filename" ));
3772
+ }
3773
+
3768
3774
CWallet * const pwallet = CreateWalletFromFile (walletFile);
3769
3775
if (!pwallet) {
3770
3776
return false ;
You can’t perform that action at this time.
0 commit comments