diff options
| author | Lola Dam <[email protected]> | 2018-01-04 23:07:08 +0100 |
|---|---|---|
| committer | Ross Nicoll <[email protected]> | 2018-09-19 19:24:06 +0100 |
| commit | 65342fa48fd2609191315a87cbebd13d7744992f (patch) | |
| tree | 3a56c943a84d4fb98683e7b9fa50f19d68cdc2d0 /src/wallet/wallet.cpp | |
| parent | Update dogecoin-tx tests (#1409) (diff) | |
| download | discoin-65342fa48fd2609191315a87cbebd13d7744992f.tar.xz discoin-65342fa48fd2609191315a87cbebd13d7744992f.zip | |
Verify when doing 'backupwallet' that destination is not the same path of the original wallet.dat file. (#1406)
Diffstat (limited to 'src/wallet/wallet.cpp')
| -rw-r--r-- | src/wallet/wallet.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 3d35bc11e..0e09dc70d 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -463,21 +463,21 @@ bool CWallet::Verify() } catch (const boost::filesystem::filesystem_error&) { // failure is ok (well, not really, but it's not worse than what we started with) } - + // try again if (!bitdb.Open(GetDataDir())) { // if it still fails, it probably means we can't even create the database env return InitError(strprintf(_("Error initializing wallet database environment %s!"), GetDataDir())); } } - + if (GetBoolArg("-salvagewallet", false)) { // Recover readable keypairs: if (!CWalletDB::Recover(bitdb, walletFile, true)) return false; } - + if (boost::filesystem::exists(GetDataDir() / walletFile)) { CDBEnv::VerifyResult r = bitdb.Verify(walletFile, CWalletDB::Recover); @@ -492,7 +492,7 @@ bool CWallet::Verify() if (r == CDBEnv::RECOVER_FAIL) return InitError(strprintf(_("%s corrupt, salvage failed"), walletFile)); } - + return true; } @@ -2973,7 +2973,7 @@ bool CWallet::SetDefaultKey(const CPubKey &vchPubKey) /** * Mark old keypool keys as used, - * and generate all new keys + * and generate all new keys */ bool CWallet::NewKeyPool() { @@ -3898,6 +3898,11 @@ bool CWallet::BackupWallet(const std::string& strDest) pathDest /= strWalletFile; try { + if (boost::filesystem::equivalent(pathSrc, pathDest)) { + LogPrintf("cannot backup to wallet source file %s\n", pathDest.string()); + return false; + } + #if BOOST_VERSION >= 104000 boost::filesystem::copy_file(pathSrc, pathDest, boost::filesystem::copy_option::overwrite_if_exists); #else |