aboutsummaryrefslogtreecommitdiff
path: root/src/pubkey.cpp
diff options
context:
space:
mode:
authorAntoine Poinsot <darosior@protonmail.com>2022-07-19 11:58:16 +0200
committerAntoine Poinsot <darosior@protonmail.com>2022-08-04 11:32:26 +0200
commitfb9faffae3a26b8aed8b671864ba679747163019 (patch)
tree5f3e9a35cf03804330e53a28bb33c2a416e06fd5 /src/pubkey.cpp
parent8dc6670ce159c2b080e9f735c6603a601d40b6ac (diff)
downloadbitcoin-fb9faffae3a26b8aed8b671864ba679747163019.tar.xz
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.
Diffstat (limited to 'src/pubkey.cpp')
-rw-r--r--src/pubkey.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/pubkey.cpp b/src/pubkey.cpp
index 324f681a0a..0b94868d1f 100644
--- a/src/pubkey.cpp
+++ b/src/pubkey.cpp
@@ -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);