mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-10 07:14:46 +03:00
Catch malformed value in TIFF
This commit is contained in:
parent
5f1a042293
commit
0788efd272
|
@ -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
BIN
Tests/images/malformed.tiff
Normal file
Binary file not shown.
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user