Skip to content

Commit

Permalink
Fix for buffer overflow in TiffDecode.c CVE-2016-0740
Browse files Browse the repository at this point in the history
  • Loading branch information
wiredfool committed Feb 4, 2016
1 parent 5bdf54b commit 6dcbf5b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions Tests/check_libtiff_segfault.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from helper import unittest, PillowTestCase
from PIL import Image

TEST_FILE = "Tests/images/libtiff_segfault.tif"

class TestLibtiffSegfault(PillowTestCase):
def test_segfault(self):
""" This test should not segfault. It will on Pillow <= 3.1.0 and
libtiff >= 4.0.0
"""

try:
im = Image.open(TEST_FILE)
im.load()
except IOError:
self.assertTrue(True, "Got expected IOError")
except Exception:
self.fail("Should have returned IOError")



if __name__ == '__main__':
unittest.main()
Binary file added Tests/images/libtiff_segfault.tif
Binary file not shown.
2 changes: 1 addition & 1 deletion libImaging/TiffDecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ int ImagingLibTiffDecode(Imaging im, ImagingCodecState state, UINT8* buffer, int
char *filename = "tempfile.tif";
char *mode = "r";
TIFF *tiff;
int size;
tsize_t size;


/* buffer is the encoded file, bytes is the length of the encoded file */
Expand Down

0 comments on commit 6dcbf5b

Please sign in to comment.