Skip to content

cap escape length in huffman_spectral_data_2 - #228

Merged
fabiangreffrath merged 1 commit into
knik0:masterfrom
netliomax25-code:hcr-escape-length-cap
Jul 13, 2026
Merged

cap escape length in huffman_spectral_data_2#228
fabiangreffrath merged 1 commit into
knik0:masterfrom
netliomax25-code:hcr-escape-length-cap

Conversation

@netliomax25-code

Copy link
Copy Markdown
Contributor
  1. huffman_spectral_data_2 reads the ER/HCR spectral escape with an unbounded length loop, for (i = 4; ; i++), rejected only at i > 32.
  2. the standard escape decoder huffman_getescape in the same file caps the length at i < 16 and returns an error for i >= 16, so an over-long escape prefix is accepted here where the standard path rejects it.
  3. the wide bound also permits j = off + (1 << i) to shift by up to 32 bits, out of range for the int expression.

Capped the loop at i < 16 and reject i >= 16, matching huffman_getescape. Escapes of length 15 or less, i.e. all well-formed streams, decode unchanged.

The ER/HCR escape loop was bounded only at i > 32, while the standard decoder huffman_getescape caps the escape length at i < 16. Cap the HCR loop the same way and reject i >= 16 so over-long escapes are refused as in the standard path; escapes up to length 15 decode unchanged.
@fabiangreffrath
fabiangreffrath merged commit 2c74fc1 into knik0:master Jul 13, 2026
6 checks 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