HomePhabricator

Improve asmap checks and add sanity check

Description

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>

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

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

Details

Provenance
Pieter Wuille <pieter.wuille@gmail.com>Authored on Apr 3 2020, 01:22
FabienCommitted on Jan 25 2021, 21:34
FabienPushed on Jan 25 2021, 21:36
Reviewer
Restricted Project
Differential Revision
D9055: Improve asmap checks and add sanity check
Parents
rABC15eb13e42302: tests: Add fuzzing harness for MessageSign, MessageVerify and other functions…
Branches
Unknown
Tags
Unknown