aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Maxwell <greg@xiph.org>2015-10-29 18:24:49 +0000
committerGregory Maxwell <greg@xiph.org>2015-10-29 18:24:49 +0000
commit30d9662bd780e298516d514984ced1f88ec5bc3b (patch)
treea0836c96114e13b28dc4cbd46d4a3ef875212866
parent725539ea03769416d3502feeb4dfcbec3fbb7ae0 (diff)
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).
-rw-r--r--src/wallet/walletdb.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp
index 0624e442d1..ea8a4eb043 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<unsigned char> vchPubKey;
+ CPubKey vchPubKey;
ssKey >> vchPubKey;
+ if (!vchPubKey.IsValid())
+ {
+ strErr = "Error reading wallet database: CPubKey corrupt";
+ return false;
+ }
vector<unsigned char> vchPrivKey;
ssValue >> vchPrivKey;
wss.nCKeys++;