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

Seek past the data when skipping a PSD layer #7483

Merged
merged 1 commit into from
Dec 21, 2023

Conversation

radarhere
Copy link
Member

Resolves #7482

When reading through layers in a PSD, Pillow skips layers that have more than 4 channels.

# image info
mode = []
ct_types = i16(read(2))
types = list(range(ct_types))
if len(types) > 4:
continue
for _ in types:
type = i16(read(2))

However, when doing so, there is only a continue. It ignores the fact that there is still data in this file relating to the current layer, that we would have started reading otherwise.

This PR skips past the rest of the layer. I created a test image in GIMP, using a layer mask as the fifth channel for a layer, and then adding another layer after that.

@hugovk hugovk merged commit 7e30619 into python-pillow:main Dec 21, 2023
50 checks passed
@radarhere radarhere deleted the psd branch December 21, 2023 10:51
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.

Photoshop PSD errors with Truncated File Read
2 participants