Repository navigation
Conversation
When the output buffer fills in the middle of a lit/len decode table entry that holds literals followed by a length, the decoders keep the literals in write_overflow_lits and still decode the length and its distance, so that the copy can resume after the literals. The match starts after the held literals, so its distance also counts them, but the decoders check it against the output written so far. When the distance is longer than that, which happens when the match copies from the first byte or two of the output, isal_inflate_stateless() returns ISAL_INVALID_LOOKBACK for a valid stream instead of ISAL_OUT_OVERFLOW. Count the held literals in the check, in the x86, aarch64 and C decoders. The x86 and aarch64 decoders lower their copy of start_out by the number of held literals on that path, which ends the call, and the C decoder adds them to the distance it allows. Add two such streams to igzip_rand_test, "a" and "ab" each followed by a copy of 3, and check that inflating them stateless into each smaller output buffer returns ISAL_OUT_OVERFLOW with the start of the output. Signed-off-by: Parker Loflin <parker@cronstable.dev>
ptweezy
force-pushed
the
igzip-inflate-pending-lits-lookback
branch
from
October 21, 2026 21:27
1452f39 to
6266dd2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
isal_inflate_stateless()returnsISAL_INVALID_LOOKBACKinstead ofISAL_OUT_OVERFLOWfor some valid streams when the output buffer is too small. When the buffer fills inside a lit/len table entry that holds literals and a length, the decoders keep the literals inwrite_overflow_litsand check the match distance against the output written so far. But the match starts after the held literals, so its distance counts them too: when the match copies from the first byte or two of the output, the distance is longer than the output written and the check fails.Decoders
All decoders have the bug: x86
_01and_04, aarch64, and C (used byarch=noarchand riscv64). On that path, which ends the call, this PR makes the x86 and aarch64 decoders lower their copy ofstart_outby the held literals, and the C decoder add them to the allowed distance.isal_inflate()is not affected, decoded output does not change, and no invalid stream is accepted.Testing
igzip_rand_testinflates two hand-built streams ("a" or "ab", then a copy of 3) stateless into every smaller buffer. It fails without the fix and passes with it on x86_04and_01,arch=noarch, aarch64 and riscv64 under qemu, and natively on Windows.make -f Makefile.unx checkpasses on x86 (_04and_01),arch=noarch, aarch64 under qemu, and natively on Windows on a Ryzen 7 9800X3D (mingw-w64 x86_64 and i686).