Skip to content

Commit 51f7668

Browse files
committed
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.
1 parent 051ba32 commit 51f7668

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/addrman_impl.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ static constexpr int ADDRMAN_NEW_BUCKET_COUNT{1 << ADDRMAN_NEW_BUCKET_COUNT_LOG2
3232
static constexpr int32_t ADDRMAN_BUCKET_SIZE_LOG2{6};
3333
static constexpr int ADDRMAN_BUCKET_SIZE{1 << ADDRMAN_BUCKET_SIZE_LOG2};
3434

35-
/** User-defined type for the internally used nIds */
36-
using nid_type = int;
35+
/**
36+
* User-defined type for the internally used nIds
37+
* This used to be int, making it feasible for attackers to cause an overflow,
38+
* see https://bitcoincore.org/en/2024/07/31/disclose-addrman-int-overflow/
39+
*/
40+
using nid_type = int64_t;
3741

3842
/**
3943
* Extended statistics about a CAddress

0 commit comments

Comments
 (0)