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

PSD reading: don't reject padded thumbnails #3677

Merged
merged 1 commit into from
Nov 18, 2022

Conversation

lgritz
Copy link
Collaborator

@lgritz lgritz commented Nov 16, 2022

When reading PSD file, if reading the thumbnail doesn't pass basic sanity checks, we consider that a hard error reading the file. One check that we do is to make sure that our computation of the byte width of the uncompressed thumbnail (bpp/8 * width) matches what the file says the widthbytes is.

BUT... it seems that it might round up to an even (or maybe 4-multiple?) of columns, presumably for scanline alignment reasons. And so we were considering whole PDF files unreadable if they fell into this case.

This PR primaril loosens the test to allow some padding up to a multiple of 4.

Fixes #3658

When reading PSD file, if reading the thumbnail doesn't pass basic
sanity checks, we consider that a hard error reading the file.  One
check that we do is to make sure that our computation of the byte
width of the uncompressed thumbnail (`bpp/8 * width`) matches what the
file says the `widthbytes` is.

BUT... it seems that it might round up to an even (or maybe 4-multiple?)
of columns, presumably for scanline alignment reasons. And so we were
considering whole PDF files unreadable if they fell into this case.

This PR primaril loosens the test to allow some padding up to a
multiple of 4.

Fixes 3658
@lgritz lgritz merged commit ce03d56 into AcademySoftwareFoundation:master Nov 18, 2022
@lgritz lgritz deleted the lg-psdpad branch November 19, 2022 06:52
lgritz added a commit to lgritz/OpenImageIO that referenced this pull request Nov 26, 2022
…n#3677)

When reading PSD file, if reading the thumbnail doesn't pass basic
sanity checks, we consider that a hard error reading the file.  One
check that we do is to make sure that our computation of the byte
width of the uncompressed thumbnail (`bpp/8 * width`) matches what the
file says the `widthbytes` is.

BUT... it seems that it might round up to an even (or maybe 4-multiple?)
of columns, presumably for scanline alignment reasons. And so we were
considering whole PDF files unreadable if they fell into this case.

This PR primarily loosens the test to allow some padding up to a
multiple of 4.

Fixes AcademySoftwareFoundation#3658
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.

Legal PSD file cannot be opened
1 participant