HomePhabricator

addrman: Avoid crash on corrupt data, Force Check after deserialize

Description

addrman: Avoid crash on corrupt data, Force Check after deserialize

Summary:

Assert should only be used for program internal logic errors, not to sanitize external user input.
The assert was introduced via the debug-only runtime option -checkaddrman in commit 803ef70, thus won't need a backport.
Also, it doesn't really make sense to continue when the deserialized addrman doesn't pass the sanity check.
For example, if nLastSuccess is negative, it would later result in integer overflows.

Backport of core#22734.

Depends on D12310.

Test Plan:

ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D12311

Details

Provenance
MarcoFalke <falke.marco@gmail.com>Authored on Aug 18 2021, 07:07
FabienCommitted on Oct 19 2022, 16:42
FabienPushed on Oct 19 2022, 16:42
Reviewer
Restricted Project
Differential Revision
D12311: addrman: Avoid crash on corrupt data, Force Check after deserialize
Parents
rABC99186d0e2508: test: Add addrman deserialization error tests
Branches
Unknown
Tags
Unknown