diff options
author | fanquake <fanquake@gmail.com> | 2022-05-04 18:57:49 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2022-05-04 18:57:53 +0100 |
commit | 33aaf434af2740d33abc0f45f613a666092630c3 (patch) | |
tree | a653fe4ea8f750dbdef9e38a0a7d231333ec5400 /src | |
parent | 0047d9b89b9fa6be660c363961cf0af72fa62ecf (diff) | |
parent | e5d183151709ab59d2fa6fe9e0243000e8d6abbe (diff) | |
download | bitcoin-33aaf434af2740d33abc0f45f613a666092630c3.tar.xz |
Merge bitcoin/bitcoin#24976: netgroup: Follow-up for #22910
e5d183151709ab59d2fa6fe9e0243000e8d6abbe [netgroup] Use nStartByte as offset for the last byte of the group (dergoegge)
Pull request description:
This addresses my review [comments](https://github.com/bitcoin/bitcoin/pull/22910#discussion_r856095896) I left on #22910.
This has no effect on the current logic as `nStartByte` is only used for internal addresses which only ever add 10 whole bytes to the returned group. However to avoid future bugs, I think we should use `nStartByte` as offset for the last byte as well, in case we ever add a new address type that makes makes use of `nStartByte` and adds fractional bytes to the group.
ACKs for top commit:
jnewbery:
Code review ACK e5d183151709ab59d2fa6fe9e0243000e8d6abbe
theStack:
Concept and code-review ACK e5d183151709ab59d2fa6fe9e0243000e8d6abbe
Tree-SHA512: 4c08c7d6cb38b553e998798b3e3b790177aaa2141a48e277dfd538e01a7fccadf644329e93c5b0fb5e7e4037494c8dfe061b94eb52c6b31dc21bdf99eb0e311a
Diffstat (limited to 'src')
-rw-r--r-- | src/netgroup.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/netgroup.cpp b/src/netgroup.cpp index 5f42d6c719..96b5e29684 100644 --- a/src/netgroup.cpp +++ b/src/netgroup.cpp @@ -71,7 +71,7 @@ std::vector<unsigned char> NetGroupManager::GetGroup(const CNetAddr& address) co // ...for the last byte, push nBits and for the rest of the byte push 1's if (nBits > 0) { assert(num_bytes < addr_bytes.size()); - vchRet.push_back(addr_bytes[num_bytes] | ((1 << (8 - nBits)) - 1)); + vchRet.push_back(addr_bytes[num_bytes + nStartByte] | ((1 << (8 - nBits)) - 1)); } return vchRet; |