Skip to content
Permalink
Browse files

Merge fd04284 into 6de118a

  • Loading branch information...
paddywwoof committed Aug 11, 2019
2 parents 6de118a + fd04284 commit 9664c2ba98359dcbc21e42cb1053a13ff9b48565
Showing with 14 additions and 1 deletion.
  1. BIN Tests/images/corrupt_exif.jpg
  2. +8 −0 Tests/test_file_jpeg.py
  3. +6 −1 src/PIL/TiffImagePlugin.py
Binary file not shown.
@@ -633,6 +633,14 @@ def test_ifd_offset_exif(self):
# Act / Assert
self.assertEqual(im._getexif()[306], "2017:03:13 23:03:09")

def test_bad_exif_overflow_32(self):
# This image has some corrupt exif offsets that unpack to values greater
# than ssize_t on 32 bit systems
im = Image.open("Tests/images/corrupt_exif.jpg")
assert (
im is not None
) # if previous line fails, im will be undefined and assertion fail

def test_photoshop(self):
im = Image.open("Tests/images/photoshop-200dpi.jpg")
self.assertEqual(
@@ -771,7 +771,12 @@ def load(self, fp):
"Tag Location: %s - Data Location: %s" % (here, offset),
end=" ",
)
fp.seek(offset)
try:
fp.seek(offset)
except OverflowError as e:
if DEBUG:
print("Offset too large. Possibly corrupt EXIF data.", e)
continue # ignore corrupt EXIF data
data = ImageFile._safe_read(fp, size)
fp.seek(here)
else:

0 comments on commit 9664c2b

Please sign in to comment.
You can’t perform that action at this time.