HomePhabricator

addrman: ensure old versions don't parse peers.dat

Description

addrman: ensure old versions don't parse peers.dat

Summary:

Even though the format of `peers.dat` was changed in an incompatible
way (old software versions <0.21 cannot understand the new file format),
it is not guaranteed that old versions will fail to parse it. There is a
chance that old versions parse its contents as garbage and use it.

Old versions expect the "key size" field to be 32 and fail the parsing
if it is not. Thus, we put something other than 32 in it. This will make
versions between 0.11.0 and 0.20.1 deterministically fail on the new
format. Versions prior to https://github.com/bitcoin/bitcoin/pull/5941
(<0.11.0) will still parse it as garbage.

Also, introduce a way to increment the `peers.dat` format in a way that
does not necessary make older versions refuse to read it.

Backport of core PR20284.

Depends on D9201.

Test Plan:

ninja all check-all

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Subscribers: majcosta

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

Details

Provenance
Vasil Dimov <vd@FreeBSD.org>Authored on Nov 2 2020, 10:36
FabienCommitted on Feb 11 2021, 08:31
FabienPushed on Feb 11 2021, 08:33
Reviewer
Restricted Project
Differential Revision
D9202: addrman: ensure old versions don't parse peers.dat
Parents
rABC6ade7a6442a3: tor: make a TORv3 hidden service instead of TORv2
Branches
Unknown
Tags
Unknown