Conversation
…e boundary A complete empty stream is all header, so at a realignment offset of 7 its ISLAST/ISLASTEMPTY pair straddles a byte boundary. Retracting one byte for the retained tail left the pair's high bit in a byte already handed to the caller, and the next flush_previous_stream rejected the file with BrotliFileNotCraftedForAppend. Retain both bytes when the call wrote two; every other header re-emits the second byte untouched.
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.
Concatenating an empty stream between two others aborted with
BrotliFileNotCraftedForAppendwhenever the preceding stream's sanitized bit offset was 7, andcatbrotliturned that into a panic with no output. Same class as #258, #260 and #266, reached from a different bit position.A complete empty stream is all header, so its ISLAST/ISLASTEMPTY pair is its final metablock, and at offset 7 that pair straddles a byte boundary.
shift_and_check_new_stream_headerretracted exactly one byte to form the retained tail, leaving the pair's high bit in a byte already handed to the caller; the nextflush_previous_streamsaw a lone set bit and rejected the file. It now retains both bytes when the call wrote two. For every other headerflush_previous_streamre-emits the second byte untouched, so output for streams that already worked is unchanged. A header split across twostreamcalls (output buffers under three bytes) is not covered here.The new unit test builds the straddle without an encoder (window 15) and fails before the change with
left: BrotliFileNotCraftedForAppend, right: NeedsMoreInput.Tests:
cargo fmt --check,cargo test(42 + 101),cargo test --doc,cargo test --features portable-float.