Fix Base64 position wrapping after 3 GiB - #1516
Open
carrerasdarren-cell wants to merge 1 commit into
Open
Conversation
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.
Base64 regions are recorded in Brotli's wrapped ring-buffer coordinate space,
but
WriteMetaBlockInternal()currently passes the unwrapped 64-bitlast_flush_posto the metablock and storage helpers. Once a streaming inputreaches the 3 GiB position-wrap boundary, a newly detected Base64 region near
the wrapped 1 GiB position appears to be behind the unwrapped current position.
It is consequently mapped to literal offset zero, and the Base64 histogram is
applied to unrelated bytes at the start of the metablock.
The encoder reports success, but the official decoder rejects the resulting
stream with
BROTLI_DECODER_ERROR_FORMAT_PADDING_2.This change restores the wrapped
last_flush_posused before Base64 mode wasintroduced and passes that consistent coordinate to the ring-buffer,
metablock, and storage helpers.
The defect is limited to the opt-in
BROTLI_PARAM_BASE64_MODEand streams thatcross the 3 GiB internal position boundary. It is distinct from #1509 and the
histogram-count fix in
0d1f629; current master after that fix still reproducesthis position mismatch.
Validation on current master
8e10eeb3378f6c459dbaf033ca6727e9816afccb:stream one 1 MiB block below the boundary.
source and round-trips after this change.
git diff --checkpasses.