Skip to content

Commit

Permalink
#955: PSD: Fix overflow issue found in GIMP PSD
Browse files Browse the repository at this point in the history
  • Loading branch information
haraldk committed Jun 4, 2024
1 parent 83cff35 commit fa49dd9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ public boolean hasMoreElements() {

@Override
public InputStream nextElement() {
return new SubStream(new DecoderStream(createStreamAdapter(stream, byteCounts[index++]), new PackBitsDecoder(), rowLength), rowLength);
// Add 128 bytes extra buffer as worst case if the encoder (GIMP) added garbage bytes at the end
return new SubStream(new DecoderStream(createStreamAdapter(stream, byteCounts[index++]), new PackBitsDecoder(), rowLength + 128), rowLength);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ protected List<TestData> getTestData() {
// CMYK, uncompressed + contains some uncommon MeSa (instead of 8BIM) resource blocks
new TestData(getClassLoaderResource("/psd/fruit-cmyk-MeSa-resource.psd"), new Dimension(400, 191)),
// 3 channel, RGB, 32 bit samples
new TestData(getClassLoaderResource("/psd/32bit5x5.psd"), new Dimension(5, 5))
new TestData(getClassLoaderResource("/psd/32bit5x5.psd"), new Dimension(5, 5)),
// 3 channel, RGB, written by GIMP, compressed with PackBits runs longer than the row length
new TestData(getClassLoaderResource("/psd/gimp-32x32-packbits-overflow.psd"), new Dimension(32, 32))
// TODO: Need more recent ZIP compressed PSD files from CS2/CS3+
);
}
Expand Down
Binary file not shown.

0 comments on commit fa49dd9

Please sign in to comment.