Skip to content

Commit 30d9662

Browse files
committed
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).
1 parent 725539e commit 30d9662

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/wallet/walletdb.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,13 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
512512
}
513513
else if (strType == "ckey")
514514
{
515-
vector<unsigned char> vchPubKey;
515+
CPubKey vchPubKey;
516516
ssKey >> vchPubKey;
517+
if (!vchPubKey.IsValid())
518+
{
519+
strErr = "Error reading wallet database: CPubKey corrupt";
520+
return false;
521+
}
517522
vector<unsigned char> vchPrivKey;
518523
ssValue >> vchPrivKey;
519524
wss.nCKeys++;

0 commit comments

Comments
 (0)