From 30d9662bd780e298516d514984ced1f88ec5bc3b Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Thu, 29 Oct 2015 18:24:49 +0000 Subject: [PATCH] Reject invalid pubkeys when reading ckey items from the wallet. This makes the behavior more consistent with key objects and will reject some corrupted pubkeys (e.g. zero length). --- src/wallet/walletdb.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 0624e442d16..ea8a4eb043c 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -512,8 +512,13 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, } else if (strType == "ckey") { - vector vchPubKey; + CPubKey vchPubKey; ssKey >> vchPubKey; + if (!vchPubKey.IsValid()) + { + strErr = "Error reading wallet database: CPubKey corrupt"; + return false; + } vector vchPrivKey; ssValue >> vchPrivKey; wss.nCKeys++;