This commit is contained in:
Andrew Murray 2015-12-14 21:26:26 +00:00
commit b9659780be
3 changed files with 7 additions and 0 deletions

View File

@ -404,6 +404,8 @@ class ImageFileDirectory_v2(collections.MutableMapping):
if info.length == 1:
if legacy_api and self.tagtype[tag] in [5, 10]:
values = values,
if len(values) != 1:
raise TypeError("A tag was malformed")
dest[tag], = values
else:
dest[tag] = values

BIN
Tests/images/malformed.tiff Normal file

Binary file not shown.

View File

@ -107,6 +107,11 @@ class TestFileTiff(PillowTestCase):
self.assertRaises(SyntaxError,
lambda: TiffImagePlugin.TiffImageFile(invalid_file))
def test_malformed_value(self):
malformed_file = "Tests/images/malformed.tiff"
self.assertRaises(IOError, lambda: Image.open(malformed_file))
def test_bad_exif(self):
i = Image.open('Tests/images/hopper_bad_exif.jpg')
try: