Skip to content

malformed hintsfile parsing - #11

Merged
rustaceanrob merged 2 commits into
2140-dev:masterfrom
csgui:fix/malformed-hintsfile-parsing
Oct 14, 2026
Merged

rustaceanrob merged 2 commits into
2140-dev:masterfrom
csgui:fix/malformed-hintsfile-parsing

Conversation

@csgui

@csgui csgui commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Malformed hintsfiles can cause the parser to panic instead of returning an error.

This was verified during Floresta swift-sync work, where a malformed hintsfile caused the node to panic. As a library, hintsfile ideally should report malformed input through the Result API so callers can handle the failure gracefully.

This PR updates the parser to return InvalidData for unsupported compact-size prefixes, invalid Elias-Fano parameters and inconsistent high-bit counts. Public signatures remain unchanged.

The first commit 4bd9472 adds a regression test that reproduces the parser panic.

csgui added 2 commits October 13, 2026 11:15
Add an 11-byte regression test expecting an error. Currently, parsing panics when ilog2() is called on zero

@rustaceanrob rustaceanrob left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rustaceanrob
rustaceanrob merged commit 7dfc93e into 2140-dev:master Oct 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants