HomePhabricator

Restore compatibility with old CSubNet serialization

Description

Restore compatibility with old CSubNet serialization

Summary:

#19628 changed CSubNet for IPv4 netmasks, using the first 4 bytes of
netmask rather than the last 4 to store the actual mask. Unfortunately,
CSubNet objects are serialized on disk in banlist.dat, breaking
compatibility with existing banlists (and bringing them into an
inconsistent state where entries reported in listbanned cannot be
removed).

Fix this by reverting to the old format (just for serialization). Also
add a sanity check to the deserializer so that nonsensical banlist.dat
entries are ignored (which would otherwise be possible if someone added
IPv4 entries after #19628 but without this PR).

Backport of core PR20140.

Depends on D9176.

Test Plan:

ninja all check-all

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

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

Details

Provenance
Pieter Wuille <pieter@wuille.net>Authored on Oct 12 2020, 21:20
FabienCommitted on Feb 5 2021, 17:34
FabienPushed on Feb 5 2021, 17:36
Reviewer
Restricted Project
Differential Revision
D9178: Restore compatibility with old CSubNet serialization
Parents
rABCcbe0b91f3e28: net: change CNetAddr::ip to have flexible size
Branches
Unknown
Tags
Unknown