From ca8fb59ae14b4140e24c4d12c7b87597fd80a932 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Mon, 15 Feb 2016 16:09:13 +0100 Subject: [PATCH] wallet: Warn on unexpected EOF while salvaging wallet Check for EOF before every getline, and warn when reading gets to EOF before the end of the data. Stricter error checking could shed more light on issues such as #7463 and #7379. --- src/wallet/db.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp index 50b0f40a6..0b07cddde 100644 --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -165,6 +165,11 @@ CDBEnv::VerifyResult CDBEnv::Verify(const std::string& strFile, bool (*recoverFu return (fRecovered ? RECOVER_OK : RECOVER_FAIL); } +/* End of headers, beginning of key/value data */ +static const char *HEADER_END = "HEADER=END"; +/* End of key/value data */ +static const char *DATA_END = "DATA=END"; + bool CDBEnv::Salvage(const std::string& strFile, bool fAggressive, std::vector& vResult) { LOCK(cs_db); @@ -199,18 +204,29 @@ bool CDBEnv::Salvage(const std::string& strFile, bool fAggressive, std::vector