diff options
author | Martin Zumsande <mzumsande@gmail.com> | 2024-08-01 14:14:00 -0400 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2024-12-02 14:19:59 +0000 |
commit | 9976162a0e0847502c075ae8524b6e5cfefba0ed (patch) | |
tree | 92f20588d472d8179a27171dda6e400393aadbba | |
parent | 1d0411dc8fea96eb4d65ffef98d71f6cc4e12af5 (diff) |
addrman: change nid_type from int to int64_t
With nId being incremented for each addr received,
an attacker could cause an overflow in the past.
(https://bitcoincore.org/en/2024/07/31/disclose-addrman-int-overflow/)
Even though that attack was made infeasible by
rate-limiting (PR #22387), to be on the safe side change the
type to an int64_t.
Github-Pull: #30568
Rebased-From: 51f7668d31e2624e41c7ce77fe33162802808f3f
-rw-r--r-- | src/addrman_impl.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/addrman_impl.h b/src/addrman_impl.h index fcc1d8d778..a3246da0ee 100644 --- a/src/addrman_impl.h +++ b/src/addrman_impl.h @@ -32,8 +32,12 @@ static constexpr int ADDRMAN_NEW_BUCKET_COUNT{1 << ADDRMAN_NEW_BUCKET_COUNT_LOG2 static constexpr int32_t ADDRMAN_BUCKET_SIZE_LOG2{6}; static constexpr int ADDRMAN_BUCKET_SIZE{1 << ADDRMAN_BUCKET_SIZE_LOG2}; -/** User-defined type for the internally used nIds */ -using nid_type = int; +/** + * User-defined type for the internally used nIds + * This used to be int, making it feasible for attackers to cause an overflow, + * see https://bitcoincore.org/en/2024/07/31/disclose-addrman-int-overflow/ + */ +using nid_type = int64_t; /** * Extended statistics about a CAddress |