2021-04-09 12:10:36 +03:00
|
|
|
#!/usr/bin/env python3
|
2020-03-10 01:12:00 +03:00
|
|
|
|
|
|
|
# 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
|
2020-03-26 22:41:06 +03:00
|
|
|
# version.
|
2023-12-21 14:13:31 +03:00
|
|
|
from __future__ import annotations
|
2020-03-10 01:12:00 +03:00
|
|
|
|
|
|
|
from PIL import Image
|
|
|
|
|
2020-03-26 22:41:06 +03:00
|
|
|
repro = ("00r0_gray_l.jp2", "00r1_graya_la.jp2")
|
2020-03-10 01:12:00 +03:00
|
|
|
|
|
|
|
for path in repro:
|
2021-11-25 15:16:07 +03:00
|
|
|
with Image.open(path) as im:
|
|
|
|
try:
|
|
|
|
im.load()
|
|
|
|
except Exception as msg:
|
|
|
|
print(msg)
|