From 30443d39bd932159bbb66f88df9f34fec2100a4f Mon Sep 17 00:00:00 2001 From: Eric Soroos Date: Mon, 9 Mar 2020 22:12:00 +0000 Subject: [PATCH] Tests for jp2 overflow --- Tests/check_jp2_overflow.py | 29 +++++++++++++++++++++++++++++ Tests/images/00r0_gray_l.jp2 | Bin 0 -> 614 bytes Tests/images/00r1_graya_la.jp2 | Bin 0 -> 335 bytes 3 files changed, 29 insertions(+) create mode 100755 Tests/check_jp2_overflow.py create mode 100644 Tests/images/00r0_gray_l.jp2 create mode 100644 Tests/images/00r1_graya_la.jp2 diff --git a/Tests/check_jp2_overflow.py b/Tests/check_jp2_overflow.py new file mode 100755 index 000000000..920474c81 --- /dev/null +++ b/Tests/check_jp2_overflow.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +# Reproductions/tests for OOB read errors in FliDecode.c + +# When run in python, all of these images should fail for +# one reason or another, either as a buffer overrun, +# unrecognized datastream, or truncated image file. +# There shouldn't be any segfaults. +# +# if run like +# `valgrind --tool=memcheck python check_jp2_overflow.py 2>&1 | grep Decode.c` +# the output should be empty. There may be python issues +# in the valgrind especially if run in a debug python +# version. + + +from PIL import Image + +repro = ('00r0_gray_l.jp2', '00r1_graya_la.jp2' + ) + +for path in repro: + im = Image.open(path) + try: + im.load() + except Exception as msg: + print(msg) + + diff --git a/Tests/images/00r0_gray_l.jp2 b/Tests/images/00r0_gray_l.jp2 new file mode 100644 index 0000000000000000000000000000000000000000..28612238a9cae1a8eca050d3df28f4119624a876 GIT binary patch literal 614 zcmZQzVBpCLP*C9IYUg5LU=T?wsVvAUFj4@r8KAT-kj?;d#WFKeihwjP5c@DNva>S+ z84Uc%`8h?53_3;W#R@>KP*G}einmw;0|>LQKtv>ykww@+1}Fdb{~ySp36uvJ1~C-O z;Xva9E#hVTAH=`|lx1XK1sVB2hCx}WT&|pbhw7 z2D@tNM;pZ%nrT6Vd^D0OOJ?Ln6PlM4?kqYC#d0hz;(MCCPJSWIA#-*h!V zfBW(725#SZL1z~y>k3@z*m#hY`{c~y{fpfA_MGpu`O$NHCQtE-O)H=2HBL4&$^Uj( z?q-J8WoNt2jen*qTgH6sD_1-D_|PA#wJCc3$6pAncj{1lZ+Ib=V}r)BRWUo|-G1^5 z3O}9O>~QGhalX{^#(R`l{Iw!?9LZW_*ZuVPmWbC6M1P(<`g>}U%K1rxmZgz5d6Mh0 z%hNA=AL()Jc(`z%`|G@f_Wve%o7Nx7n$f@g##ZMaGHMdqa!Up7{7z;$`)!Frr~c7H oye`)!t6uyOq2cINvQ6RbT=6iylrom<_X^UMt&U@A-249~0D?o$$^ZZW literal 0 HcmV?d00001 diff --git a/Tests/images/00r1_graya_la.jp2 b/Tests/images/00r1_graya_la.jp2 new file mode 100644 index 0000000000000000000000000000000000000000..f3f840a08e378fbdaf8cdc5b231ea6862f68ec06 GIT binary patch literal 335 zcmZQzVBpCLP*C9IYUg5LU=T?wsVvAUFj4@r8KAT?kj?;d#WFKeih#5N7&Ec6GXfb5 z{K@$_MPL?#AdoAToRXTxzyy*30!APN1E3Mf|NZ|5GU$N03P2KsVL$=M0AUDVVsB(* zXJq^z#J~d-U}RurVPRnWAHyK5;1LiI0Yd>E9s&PTfR-|PCuS$6lKW-7{-3}A z@(2S%4N%YI<5yT1X8;L~faMQZ*gl^>z`_$>WlejaJCOIozHBX{G&^n;(f8O#>WT$jAqG~@M=OACIoFwC8{l95GQ Z;KspEJPh&6k9REK-H`Btt@iQ%n*b)BSDpX> literal 0 HcmV?d00001