aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/scriptpubkeyman.cpp
diff options
context:
space:
mode:
authorRob Fielding <rob@g17.co.nz>2021-10-14 17:32:05 +1300
committerAndrew Chow <achow101-github@achow101.com>2021-12-08 11:22:29 -0500
commit0652ee73ec880a66ec88bde007ee03c0b9d1b074 (patch)
tree176cf2ac077ddf3b393bd8eb4b4c248077a93304 /src/wallet/scriptpubkeyman.cpp
parent577bd51a4b8de066466a445192c1c653872657e2 (diff)
downloadbitcoin-0652ee73ec880a66ec88bde007ee03c0b9d1b074.tar.xz
Add size check on meta.key_origin.path
Resolves segfault on legacy wallet Log warning when meta.key_origin.path is below expected size
Diffstat (limited to 'src/wallet/scriptpubkeyman.cpp')
-rw-r--r--src/wallet/scriptpubkeyman.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp
index 1769429efe..5a9755d32b 100644
--- a/src/wallet/scriptpubkeyman.cpp
+++ b/src/wallet/scriptpubkeyman.cpp
@@ -382,11 +382,18 @@ std::vector<WalletDestination> LegacyScriptPubKeyMan::MarkUnusedAddresses(const
if (it != mapKeyMetadata.end()){
CKeyMetadata meta = it->second;
if (!meta.hd_seed_id.IsNull() && meta.hd_seed_id != m_hd_chain.seed_id) {
- bool internal = (meta.key_origin.path[1] & ~BIP32_HARDENED_KEY_LIMIT) != 0;
- int64_t index = meta.key_origin.path[2] & ~BIP32_HARDENED_KEY_LIMIT;
-
- if (!TopUpInactiveHDChain(meta.hd_seed_id, index, internal)) {
- WalletLogPrintf("%s: Adding inactive seed keys failed\n", __func__);
+ if (meta.key_origin.path.size() < 3) {
+ WalletLogPrintf("%s: Adding inactive seed keys failed, insufficient path size: %d, has_key_origin: %s\n",
+ __func__,
+ meta.key_origin.path.size(),
+ meta.has_key_origin);
+ } else {
+ bool internal = (meta.key_origin.path[1] & ~BIP32_HARDENED_KEY_LIMIT) != 0;
+ int64_t index = meta.key_origin.path[2] & ~BIP32_HARDENED_KEY_LIMIT;
+
+ if (!TopUpInactiveHDChain(meta.hd_seed_id, index, internal)) {
+ WalletLogPrintf("%s: Adding inactive seed keys failed\n", __func__);
+ }
}
}
}