aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTomas van der Wansem <tomas@tomasvdw.nl>2017-09-21 00:10:46 +0200
committerMarcoFalke <falke.marco@gmail.com>2017-11-01 15:23:06 -0400
commitfd79ed6b202ec872aa794ba6a23d4dfc373a98f1 (patch)
tree9a8e2ce5deba2c1ba8dd4c0da0145275624d80cc /src
parentd94fc336c47b5fd0f42217806faad1aa201b9d63 (diff)
Ensure backupwallet fails when attempting to backup to source file
Previous behaviour was to destroy the wallet (to zero-length) Github-Pull: #11376 Rebased-From: 5d465e396249a0e2cc60b16984a2bdbe4c8993c3
Diffstat (limited to 'src')
-rw-r--r--src/wallet/db.cpp5
-rw-r--r--src/wallet/db.h2
2 files changed, 6 insertions, 1 deletions
diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp
index d2fe4866fa..8c23d9c072 100644
--- a/src/wallet/db.cpp
+++ b/src/wallet/db.cpp
@@ -673,6 +673,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;
diff --git a/src/wallet/db.h b/src/wallet/db.h
index 3614e34fbb..6f3cfe9557 100644
--- a/src/wallet/db.h
+++ b/src/wallet/db.h
@@ -45,7 +45,7 @@ public:
void Reset();
void MakeMock();
- bool IsMock() { return fMockDb; }
+ bool IsMock() const { return fMockDb; }
/**
* Verify that database file strFile is OK. If it is not,