Skip to content

Commit 100d67c

Browse files
luke-jrrandom-zebra
authored andcommitted
Wallet: Sanitise -wallet parameter
1 parent 3bfa7d8 commit 100d67c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/wallet/wallet.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4351,6 +4351,12 @@ bool CWallet::InitLoadWallet()
43514351

43524352
std::string walletFile = gArgs.GetArg("-wallet", DEFAULT_WALLET_DAT);
43534353

4354+
if (walletFile.find_first_of("/\\") != std::string::npos) {
4355+
return UIError(_("-wallet parameter must only specify a filename (not a path)"));
4356+
} else if (SanitizeString(walletFile, SAFE_CHARS_FILENAME) != walletFile) {
4357+
return UIError(_("Invalid characters in -wallet filename"));
4358+
}
4359+
43544360
CWallet * const pwallet = CreateWalletFromFile(walletFile);
43554361
if (!pwallet) {
43564362
return false;

0 commit comments

Comments
 (0)