Page MenuHomePhabricator

Improve asmap checks and add sanity check
ClosedPublic

Authored by Fabien on Jan 25 2021, 16:34.

Details

Reviewers
PiRK
Group Reviewers
Restricted Project
Commits
rABCeda85704fcd2: Improve asmap checks and add sanity check
Summary
This improves/documents the failure cases inside the asmap interpreter. None of the changes are bug fixes (they only change behavior for corrupted asmap files), but they may make things easier to follow.

In a second step, a sanity checker is added that effectively executes every potential code path through the asmap file, checking the same failure cases as the interpreter, and more. It takes around 30 ms to run for me for a 1.2 MB asmap file.

I've verified that this accepts asmap files constructed by https://github.com/sipa/asmap/blob/master/buildmap.py with a large dataset, and no longer accepts it with 1 bit changed in it.

Backport of core PR18512.

Test Plan
ninja all check-all
ninja bitcoin-fuzzers
./test/fuzz/test_runner.py <path_to_corpus>