mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 02:25:40 +01:00
Add size check on meta.key_origin.path
Resolves segfault on legacy wallet Log warning when meta.key_origin.path is below expected size
This commit is contained in:
parent
577bd51a4b
commit
0652ee73ec
@ -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 (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__);
|
||||
if (!TopUpInactiveHDChain(meta.hd_seed_id, index, internal)) {
|
||||
WalletLogPrintf("%s: Adding inactive seed keys failed\n", __func__);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user