diff --git a/Tests/images/crash-81154a65438ba5aaeca73fd502fa4850fbde60f8.tif b/Tests/images/crash-81154a65438ba5aaeca73fd502fa4850fbde60f8.tif new file mode 100644 index 000000000..56e824199 Binary files /dev/null and b/Tests/images/crash-81154a65438ba5aaeca73fd502fa4850fbde60f8.tif differ diff --git a/Tests/test_tiff_crashes.py b/Tests/test_tiff_crashes.py index 7b01d458e..a8e378ec1 100644 --- a/Tests/test_tiff_crashes.py +++ b/Tests/test_tiff_crashes.py @@ -34,6 +34,7 @@ from .helper import on_ci "Tests/images/crash-f46f5b2f43c370fe65706c11449f567ecc345e74.tif", "Tests/images/crash-63b1dffefc8c075ddc606c0a2f5fdc15ece78863.tif", "Tests/images/crash-74d2a78403a5a59db1fb0a2b8735ac068a75f6e3.tif", + "Tests/images/crash-81154a65438ba5aaeca73fd502fa4850fbde60f8.tif", ], ) diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index 24821d130..9d821dcf9 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -1250,6 +1250,10 @@ class TiffImageFile(ImageFile.ImageFile): if bps_count > len(bps_tuple) and len(bps_tuple) == 1: bps_tuple = bps_tuple * bps_count + samplesPerPixel = self.tag_v2.get(SAMPLESPERPIXEL, 1) + if len(bps_tuple) != samplesPerPixel: + raise SyntaxError("unknown data organization") + # mode: check photometric interpretation and bits per pixel key = ( self.tag_v2.prefix,