mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Ensure backupwallet fails when attempting to backup to source file
Previous behaviour was to destroy the wallet (to zero-length)
This commit is contained in:
@@ -672,6 +672,11 @@ bool CWalletDBWrapper::Backup(const std::string& strDest)
|
||||
pathDest /= strFile;
|
||||
|
||||
try {
|
||||
if (fs::equivalent(pathSrc, pathDest)) {
|
||||
LogPrintf("cannot backup to wallet source file %s\n", pathDest.string());
|
||||
return false;
|
||||
}
|
||||
|
||||
fs::copy_file(pathSrc, pathDest, fs::copy_option::overwrite_if_exists);
|
||||
LogPrintf("copied %s to %s\n", strFile, pathDest.string());
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user