mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 01:16:16 +03:00
Raise ValueError if PNG sRGB chunk is truncated
This commit is contained in:
parent
4db2ed3a6f
commit
40a0999303
|
@ -635,7 +635,9 @@ class TestFilePng:
|
|||
|
||||
assert_image_equal_tofile(im, "Tests/images/bw_gradient.png")
|
||||
|
||||
@pytest.mark.parametrize("cid", (b"IHDR", b"pHYs", b"acTL", b"fcTL", b"fdAT"))
|
||||
@pytest.mark.parametrize(
|
||||
"cid", (b"IHDR", b"sRGB", b"pHYs", b"acTL", b"fcTL", b"fdAT")
|
||||
)
|
||||
def test_truncated_chunks(self, cid):
|
||||
fp = BytesIO()
|
||||
with PngImagePlugin.PngStream(fp) as png:
|
||||
|
|
|
@ -509,6 +509,10 @@ class PngStream(ChunkStream):
|
|||
# 3 absolute colorimetric
|
||||
|
||||
s = ImageFile._safe_read(self.fp, length)
|
||||
if length < 1:
|
||||
if ImageFile.LOAD_TRUNCATED_IMAGES:
|
||||
return s
|
||||
raise ValueError("Truncated sRGB chunk")
|
||||
self.im_info["srgb"] = s[0]
|
||||
return s
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user