Skip to content

PSD reading: don't reject padded thumbnails #3677

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

Merged
merged 1 commit into from
Nov 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/psd.imageio/psdinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ PSDInput::load_resource_thumbnail(uint32_t length, bool isBGR)
bpp);
return false;
}
if ((bpp / 8) * width != widthbytes) {
if ((bpp / 8) * width > widthbytes || (bpp / 8) * width + 3 < widthbytes) {
errorfmt("Corrupt thumbnail: {}w * {}bpp does not match {} width bytes",
width, bpp, widthbytes);
return false;
Expand Down Expand Up @@ -1311,9 +1311,10 @@ PSDInput::load_resource_thumbnail(uint32_t length, bool isBGR)
m_thumbnail.read(0, 0, true);

// Set these attributes for the merged composite only (subimage 0)
composite_attribute("thumbnail_width", (int)width);
composite_attribute("thumbnail_height", (int)height);
composite_attribute("thumbnail_nchannels", 3);
composite_attribute("thumbnail_width", (int)m_thumbnail.spec().width);
composite_attribute("thumbnail_height", (int)m_thumbnail.spec().height);
composite_attribute("thumbnail_nchannels",
(int)m_thumbnail.spec().nchannels);
if (isBGR)
m_thumbnail = ImageBufAlgo::channels(m_thumbnail, 3, { 2, 1, 0 });
return true;
Expand Down