extended keys: fail to derive too large depth instead of wrapping around

This issue was reported to me by Marco Falke, and found with the
descriptor_parse fuzz target.
This commit is contained in:
Antoine Poinsot committed 2022-08-04 11:32:26 +02:00
1 parent 8dc6670ce1
commit fb9faffae3
3 files changed
+20

No files matched your search

+1
View File
@@ -365,6 +365,7 @@ void CExtPubKey::DecodeWithVersion(const unsigned char code[BIP32_EXTKEY_WITH_VE
}
bool CExtPubKey::Derive(CExtPubKey &out, unsigned int _nChild) const {
if (nDepth == std::numeric_limits<unsigned char>::max()) return false;
out.nDepth = nDepth + 1;
CKeyID id = pubkey.GetID();
memcpy(out.vchFingerprint, &id, 4);