diff options
author | Antoine Poinsot <darosior@protonmail.com> | 2022-07-19 11:58:16 +0200 |
---|---|---|
committer | Antoine Poinsot <darosior@protonmail.com> | 2022-08-04 11:32:26 +0200 |
commit | fb9faffae3a26b8aed8b671864ba679747163019 (patch) | |
tree | 5f3e9a35cf03804330e53a28bb33c2a416e06fd5 /src/key.cpp | |
parent | 8dc6670ce159c2b080e9f735c6603a601d40b6ac (diff) |
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/key.cpp')
-rw-r--r-- | src/key.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/key.cpp b/src/key.cpp index 9b0971a2dd..199808505d 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -333,6 +333,7 @@ bool CKey::Derive(CKey& keyChild, ChainCode &ccChild, unsigned int nChild, const } bool CExtKey::Derive(CExtKey &out, unsigned int _nChild) const { + if (nDepth == std::numeric_limits<unsigned char>::max()) return false; out.nDepth = nDepth + 1; CKeyID id = key.GetPubKey().GetID(); memcpy(out.vchFingerprint, &id, 4); |