mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Block TIFFTAG_SUBIFD
This commit is contained in:
parent
0eddc82157
commit
8794610c76
|
@ -4,7 +4,7 @@ from io import BytesIO
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from PIL import Image, TiffImagePlugin
|
from PIL import Image, TiffImagePlugin
|
||||||
from PIL.TiffImagePlugin import RESOLUTION_UNIT, X_RESOLUTION, Y_RESOLUTION
|
from PIL.TiffImagePlugin import RESOLUTION_UNIT, SUBIFD, X_RESOLUTION, Y_RESOLUTION
|
||||||
|
|
||||||
from .helper import (
|
from .helper import (
|
||||||
assert_image_equal,
|
assert_image_equal,
|
||||||
|
@ -161,6 +161,14 @@ class TestFileTiff:
|
||||||
reloaded.load()
|
reloaded.load()
|
||||||
assert (round(dpi), round(dpi)) == reloaded.info["dpi"]
|
assert (round(dpi), round(dpi)) == reloaded.info["dpi"]
|
||||||
|
|
||||||
|
def test_subifd(self, tmp_path):
|
||||||
|
outfile = str(tmp_path / "temp.tif")
|
||||||
|
with Image.open("Tests/images/g4_orientation_6.tif") as im:
|
||||||
|
im.tag_v2[SUBIFD] = 10000
|
||||||
|
|
||||||
|
# Should not segfault
|
||||||
|
im.save(outfile)
|
||||||
|
|
||||||
def test_save_setting_missing_resolution(self):
|
def test_save_setting_missing_resolution(self):
|
||||||
b = BytesIO()
|
b = BytesIO()
|
||||||
Image.open("Tests/images/10ct_32bit_128.tiff").save(
|
Image.open("Tests/images/10ct_32bit_128.tiff").save(
|
||||||
|
|
|
@ -89,6 +89,7 @@ ARTIST = 315
|
||||||
PREDICTOR = 317
|
PREDICTOR = 317
|
||||||
COLORMAP = 320
|
COLORMAP = 320
|
||||||
TILEOFFSETS = 324
|
TILEOFFSETS = 324
|
||||||
|
SUBIFD = 330
|
||||||
EXTRASAMPLES = 338
|
EXTRASAMPLES = 338
|
||||||
SAMPLEFORMAT = 339
|
SAMPLEFORMAT = 339
|
||||||
JPEGTABLES = 347
|
JPEGTABLES = 347
|
||||||
|
@ -1559,12 +1560,14 @@ def _save(im, fp, filename):
|
||||||
# The other tags expect arrays with a certain length (fixed or depending on
|
# The other tags expect arrays with a certain length (fixed or depending on
|
||||||
# BITSPERSAMPLE, etc), passing arrays with a different length will result in
|
# BITSPERSAMPLE, etc), passing arrays with a different length will result in
|
||||||
# segfaults. Block these tags until we add extra validation.
|
# segfaults. Block these tags until we add extra validation.
|
||||||
|
# SUBIFD may also cause a segfault.
|
||||||
blocklist = [
|
blocklist = [
|
||||||
REFERENCEBLACKWHITE,
|
REFERENCEBLACKWHITE,
|
||||||
SAMPLEFORMAT,
|
SAMPLEFORMAT,
|
||||||
STRIPBYTECOUNTS,
|
STRIPBYTECOUNTS,
|
||||||
STRIPOFFSETS,
|
STRIPOFFSETS,
|
||||||
TRANSFERFUNCTION,
|
TRANSFERFUNCTION,
|
||||||
|
SUBIFD,
|
||||||
]
|
]
|
||||||
|
|
||||||
atts = {}
|
atts = {}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user