Page MenuHomePhabricator

addrman: change internal id counting to int64_t
ClosedPublic

Authored by Fabien on Tue, Apr 29, 10:16.

Details

Reviewers
PiRK
Group Reviewers
Restricted Project
Commits
rABCad6319bf40c7: addrman: change internal id counting to int64_t
Summary
With nIdCount being incremented for each addr received, an attacker could cause an overflow in the past, see https://bitcoincore.org/en/2024/07/31/disclose-addrman-int-overflow/
Even though that attack was made infeasible indirectly by addr rate-limiting (PR #22387), to be on the safe side and prevent any regressions change the nIds used internally to int64_t.
This is being done by first introducing a user-defined type for nIds in the first commit, and then updating it to int64_t (thanks sipa for help with this!).

Note that nId is only used internally, it is not part of the serialization, so peers.dat should not be affected by this.

I assume that the only reason this was not done in the past is to not draw attention to this previously undisclosed issue.

Backport of core#30568.

Depends on D18014.

Test Plan
ninja all check-all

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable