Refuse to compress an input the stream format cannot express - #257
Merged
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Contributor
Author
|
@googlebot I signed it! |
lenamonj
force-pushed
the
refuse-oversized-input
branch
from
September 6, 2026 09:06
a6bba59 to
29ecfbb
Compare
InternalCompress checked the 2^32-byte limit with an assert only, so every NDEBUG build compressed a larger input into a stream whose length varint held N mod 2^32 while the body carried all N bytes. The check is now a runtime refusal at the single funnel every compression entry point uses: nothing is written and zero is returned, which no successful compression can return; snappy_compress returns SNAPPY_INVALID_INPUT. The headers document the limit and a test drives a 4 GiB Source without materialising it.
lenamonj
force-pushed
the
refuse-oversized-input
branch
from
September 6, 2026 09:15
29ecfbb to
1a09131
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.
InternalCompressguarded the 2^32-byte limit with anassertonly, so every NDEBUG build compressed a larger input into a stream whose length varint heldN mod 2^32while the body carried all N bytes: a 4 GiB input produced a header claiming 0 bytes.The guard is now a runtime check at the one funnel every compression entry point passes through. An input of 2^32 bytes or more writes nothing and returns zero bytes written, which no successful compression can return;
snappy_compressreturnsSNAPPY_INVALID_INPUT. The headers document the limit. The new test drives a 4 GiBSourcewithout materialising it and fails on main (201457665 bytes written).