Skip to content

Commit 6e7c0ce

Browse files
wiredfoolhugovk
authored andcommitted
Tests for tiff crashes
1 parent b8d4ce1 commit 6e7c0ce

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

Tests/check_tiff_crashes.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python
2+
3+
# Reproductions/tests for crashes/read errors in TiffDecode.c
4+
5+
# When run in python, all of these images should fail for
6+
# one reason or another, either as a buffer overrun,
7+
# unrecognized datastream, or truncated image file.
8+
# There shouldn't be any segfaults.
9+
#
10+
# if run like
11+
# `valgrind --tool=memcheck python check_tiff_crashes.py 2>&1 | grep TiffDecode.c`
12+
# the output should be empty. There may be python issues
13+
# in the valgrind especially if run in a debug python
14+
# version.
15+
16+
17+
from PIL import Image
18+
19+
repro_read_strip = ('images/crash_1.tif',
20+
'images/crash_2.tif',
21+
)
22+
23+
for path in repro_read_strip:
24+
with Image.open(path) as im:
25+
try:
26+
im.load()
27+
except Exception as msg:
28+
print(msg)

Tests/images/crash_1.tif

6.36 KB
Binary file not shown.

Tests/images/crash_2.tif

6.08 KB
Binary file not shown.

0 commit comments

Comments
 (0)