Skip to content

bpo-38334: Fix seeking bug for encrypted zipfiles #16529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

danifus
Copy link
Contributor

@danifus danifus commented Oct 2, 2019

This resolves an issue where seeking on an encrypted zipfile would cause the crc keys to go out of sync resulting in bad data to be read after the seek.

https://bugs.python.org/issue38334

This centralises the logic for initialising the decompressor and
decrypter when 1. opening the file and 2. seeking backwards in a file
stream.
This commit resolves an issue where seeking on an encrypted zipfile
would cause the crc keys to go out of sync resulting in data read after
the seek to be garbled.

This commit refactors `_ZipDecrypter` to be a class (`CRCZipDecrypter`)
that can be reinitialised when seeking back to the beginning of a zipped
file. In doing so, some of the logic relating to configuring the
decrypter which was found in `ZipFile` has been moved to the decrypter
class.
@danifus
Copy link
Contributor Author

danifus commented Jun 1, 2021

Fixed by #16937

@danifus danifus closed this Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants