Repository navigation
LibCompress: Decode short Huffman symbols at end of stream - #27098
Arthur031221 wants to merge 1 commit into
Conversation
Allow lookahead to return the bits left at end of stream, then require the matched code's full bit length before consuming a symbol. This keeps truncated symbols and stream errors from being accepted.
|
How does this targeted fix compare to the comprehensive refactor by @DanShaders in #24567 ? Nico and Tim seem to have discussed using the method you are using in this patch in the referenced issues, so it might be reasonable to use it -- I didn't look very closely |
|
This fixes the synchronous path |
|
Is there anything else you need from me on this one? |
|
You should probably advertise this on #code-review in Discord. (Not sure what exactly Andrew wanted me to look at here) |
SerenityOS unzip aborts on valid source archives. In a ZIP made with
git archive --format=zip 80baeb29708a, 460 entries fail, starting atBase/home/anon/Source/js/object-expression.js.The Huffman decoder requires the full lookup width at EOF even when fewer bits contain a complete symbol. This change uses an explicit relaxed peek, then requires the matched code length. Strict streams still reject truncated symbols and propagate read errors.
Fixes #25005 and #22130.
Added tests for short symbols, truncated codes, and stream errors. Tested with
ctest --test-dir Build/lagom/Tests/LibCompress --output-on-failure.Assisted by Claude/Codex.