Skip to content

reject NLT segments whose Dmin and Dmax map to the same float - #430

Open
zayeem06 wants to merge 1 commit into
aous72:masterfrom
zayeem06:nlt-degenerate-range-check
Open

zayeem06 wants to merge 1 commit into
aous72:masterfrom
zayeem06:nlt-degenerate-range-check

Conversation

@zayeem06

Copy link
Copy Markdown
Contributor

param_nlt::read only checks that Dmin is smaller than Dmax as 32-bit integers, but nlt_rec::prepare_for_decoding maps both to floats in [0, 1], and two adjacent values such as 0xFFFFFFFE and 0xFFFFFFFF round to the same float, so the LUT ends up with a zero float range, an infinite inv_delta and a NaN index into the decode table. That reads the table out of bounds in the type 2 and type 4 irreversible NLT paths (ASan flags a wild read in the SSE2 code well before the table, and the generic path hits a NaN to unsigned conversion), and a crafted codestream can carry such an NLT marker segment. I reject the collapsing range in param_nlt::read right after the existing Dmin/Dmax integer check, computing the floats the same way the decoder does. The regression test in test_nlt.cpp inserts such a segment for both LUT types and checks that reading the headers rejects it; worth verifying that the new error path fires and that a normal full-range LUT still decodes, both of which I confirmed with the full suite (139 tests pass).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant