8000 tinfl: reject the reserved length symbols 286 and 287 by Noonamous · Pull Request #407 · richgel999/miniz · GitHub
[go: up one dir, main page]

Skip to content

tinfl: reject the reserved length symbols 286 and 287 - #407

Open
Noonamous wants to merge 1 commit into
richgel999:masterfrom
Noonamous:tinfl-reject-reserved-length-symbols
Open

Noonamous wants to merge 1 commit into
richgel999:masterfrom
Noonamous:tinfl-reject-reserved-length-symbols

Conversation

@Noonamous
Copy link
Copy Markdown

Fixes #402.

Length symbols 286 and 287 are reserved (RFC 1951 3.2.6) and never appear in valid data, but tinfl decoded them as a zero-length match and returned success. This makes them fail the same way other invalid codes do, with TINFL_STATUS_FAILED.

Only fixed-Huffman blocks can contain them, because a dynamic block's HLIT tops out at 286 codes.

Testing:

  • Both streams from the issue now return TINFL_DECOMPRESS_MEM_TO_MEM_FAILED (before the fix: 3: ABC).
  • I added a section to tests/main.cpp with both streams. It fails without the fix and passes with it.
  • ctest passes (3/3).
  • I compressed 3,000 streams with Python's zlib (raw deflate, levels 0-9, all five strategies including Z_FIXED), and all 3,000 decompress byte-for-byte with the patched tinfl under ASan/UBSan.

Length symbols 286 and 287 are reserved (RFC 1951 3.2.6) and never occur
in valid data, but tinfl decoded them as a zero-length match and returned
success. Fail on them with TINFL_STATUS_FAILED. Fixes richgel999#402.
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.

tinfl accepts the invalid length symbols 286 and 287 and decodes them as a zero-length match

1 participant

0