Repository navigation
gh-160314: Raise for a damaged later stream in lzma and bz2 - #160315
Merged
Merged
Conversation
A damaged .xz or bzip2 stream that followed another stream was taken for trailing data and silently ignored. Leftover data that starts with the stream magic is now treated as a stream, as gzip does.
Documentation build overview
88 files changed ·
|
gpshead
commented
Oct 31, 2026
gpshead
marked this pull request as ready for review
October 31, 2026 19:39
gpshead
enabled auto-merge (squash)
October 31, 2026 19:40
|
Thanks @gpshead for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15. |
|
Sorry, @gpshead, I could not cleanly backport this to Please backport manually with cherry_picker, see the devguide for more information. |
|
Sorry, @gpshead, I could not cleanly backport this to Please backport manually with cherry_picker, see the devguide for more information. |
|
GH-161034 is a backport of this pull request to the 3.15 branch. |
|
GH-161035 is a backport of this pull request to the 3.14 branch. |
gpshead
added a commit
that referenced
this pull request
Oct 31, 2026
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.
DecompressReader.read(),lzma.decompress()andbz2.decompress()now ignore leftover data after a stream only when it does not start with the format's stream magic (the six.xzheader bytes, orBZh1toBZh9as thebzip2program requires); an error in data that does start with it is propagated. This is the same heuristicgzipuses to tell another member from trailing data. Trailing junk that happens to start with the magic bytes now raises instead of being ignored. A damaged later stream in the legacy.lzmacontainer, which has no magic, is still dropped silently.This touches the same
decompress()loops inLib/bz2.pyandLib/lzma.pyas GH-160311, so the two conflict textually; whichever is merged second needs a rebase.Fixes #160314
ANT-2026-3TVAVL5A
lzmaandbz2silently ignore a damaged later stream as trailing data #160314