Page MenuHomePhabricator

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

Authored by Fabien on Wed, Feb 10, 11:27.

Details

Reviewers
majcosta
Group Reviewers
Restricted Project
Commits
rABC5be9d5e9c482: 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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Fabien requested review of this revision.Wed, Feb 10, 11:27
majcosta added a subscriber: majcosta.
majcosta added inline comments.
src/addrman.h
356–361 ↗(On Diff #27632)
This revision is now accepted and ready to land.Wed, Feb 10, 18:43