Skip to content
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

Ensure PNG seeks to end of previous chunk at start of load_end #5493

Merged
merged 1 commit into from Jun 6, 2021

Conversation

radarhere
Copy link
Member

Resolves #5491

If I copy existing test image bw_gradient.png, add padding to the end of the IDAT chunk and set the MAXBLOCK so that it is the length of the original chunk (in the issue, this is triggered with the normal MAXBLOCK value, but changing it allows the test to use a smaller image), then Pillow reads a block of image data, and stops reading, because the image data is done. However, the IDAT chunk length indicates that should have progressed further.

This leads to the next chunk being incorrectly read, which is raised as an error if LOAD_TRUNCATED_IMAGES is enabled.

This PR fixes it by reading to the end of the chunk at the start of load_end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot open untruncated png image with LOAD_TRUNCATED_IMAGES=True
2 participants