diff options
author | Luke Dashjr <luke-jr+git@utopios.org> | 2017-01-08 20:41:30 +0000 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2017-02-27 20:45:18 +0000 |
commit | d678771c660c936a6222dd43a204cb2699100f3e (patch) | |
tree | 2cbfc0f5f5cfd6c45a06c852b6a1accfc7f565e6 /src | |
parent | 9756be382e64ab060e8d8fd3cefe5bbccc44bb45 (diff) |
Wallet: Sanitise -wallet parameter
Diffstat (limited to 'src')
-rw-r--r-- | src/utilstrencodings.cpp | 3 | ||||
-rw-r--r-- | src/utilstrencodings.h | 3 | ||||
-rw-r--r-- | src/wallet/wallet.cpp | 6 |
3 files changed, 10 insertions, 2 deletions
diff --git a/src/utilstrencodings.cpp b/src/utilstrencodings.cpp index 025040c43a..29ae57940f 100644 --- a/src/utilstrencodings.cpp +++ b/src/utilstrencodings.cpp @@ -19,7 +19,8 @@ static const string CHARS_ALPHA_NUM = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO static const string SAFE_CHARS[] = { CHARS_ALPHA_NUM + " .,;-_/:?@()", // SAFE_CHARS_DEFAULT - CHARS_ALPHA_NUM + " .,;-_?@" // SAFE_CHARS_UA_COMMENT + CHARS_ALPHA_NUM + " .,;-_?@", // SAFE_CHARS_UA_COMMENT + CHARS_ALPHA_NUM + ".-_", // SAFE_CHARS_FILENAME }; string SanitizeString(const string& str, int rule) diff --git a/src/utilstrencodings.h b/src/utilstrencodings.h index cb6f014fc2..e2a1b9bef9 100644 --- a/src/utilstrencodings.h +++ b/src/utilstrencodings.h @@ -26,7 +26,8 @@ enum SafeChars { SAFE_CHARS_DEFAULT, //!< The full set of allowed chars - SAFE_CHARS_UA_COMMENT //!< BIP-0014 subset + SAFE_CHARS_UA_COMMENT, //!< BIP-0014 subset + SAFE_CHARS_FILENAME, //!< Chars allowed in filenames }; /** diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 63501b04be..446454e9e3 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3765,6 +3765,12 @@ bool CWallet::InitLoadWallet() std::string walletFile = GetArg("-wallet", DEFAULT_WALLET_DAT); + if (walletFile.find_first_of("/\\") != std::string::npos) { + return InitError(_("-wallet parameter must only specify a filename (not a path)")); + } else if (SanitizeString(walletFile, SAFE_CHARS_FILENAME) != walletFile) { + return InitError(_("Invalid characters in -wallet filename")); + } + CWallet * const pwallet = CreateWalletFromFile(walletFile); if (!pwallet) { return false; |