aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/db.cpp
diff options
context:
space:
mode:
authorTomas van der Wansem <[email protected]>2017-09-21 00:10:46 +0200
committerTomas van der Wansem <[email protected]>2017-10-10 14:49:47 +0200
commit5d465e396249a0e2cc60b16984a2bdbe4c8993c3 (patch)
treea30633f6035bf19b5d1ceca21f014a2868c45188 /src/wallet/db.cpp
parentMerge #11469: fix typo in comment of chain.cpp (diff)
downloaddiscoin-5d465e396249a0e2cc60b16984a2bdbe4c8993c3.tar.xz
discoin-5d465e396249a0e2cc60b16984a2bdbe4c8993c3.zip
Ensure backupwallet fails when attempting to backup to source file
Previous behaviour was to destroy the wallet (to zero-length)
Diffstat (limited to 'src/wallet/db.cpp')
-rw-r--r--src/wallet/db.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp
index d66ba4842..d49cd8234 100644
--- a/src/wallet/db.cpp
+++ b/src/wallet/db.cpp
@@ -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;