Skip to content

Add checked shift and allocation size validation in COVER_map_init() - #4627

Open
nidu-ninja wants to merge 1 commit into
meta:devfrom
nidu-ninja:cover-map-init-overflow-checks
Open

nidu-ninja wants to merge 1 commit into
meta:devfrom
nidu-ninja:cover-map-init-overflow-checks

Conversation

@nidu-ninja

Copy link
Copy Markdown
Contributor

This PR hardens COVER_map_init() in cover.c by adding validation for
bit shifts and allocation size computations.

The original implementation computed map size using a left shift and
performed a multiplication before malloc without validating whether
these operations could overflow.

@itsgaldoron

Copy link
Copy Markdown

This PR has been inactive since 2026-03-18. I have picked the fix up in #4887 — same root cause re-derived on current dev (reject unrepresentable COVER_map_init capacities: the sizeLog >= 32 shift UB, the size == 0 edge, and the 32-bit pair-array allocation wrap), plus the matching bound in COVER_checkParameters(), a regression test in tests/fuzzer.c, and two-state evidence (unpatched: SIGSEGV / UBSan shift-exponent abort / i386 heap-corruption abort; patched: clean parameter_out_of_bound). Happy to drop #4887 if you plan to continue here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants