mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Avoid DecompressionBombWarning: Image size (151587072 pixels) exceeds limit of 89478485 pixels, could be decompression bomb DOS attack.
This commit is contained in:
parent
474270fbd5
commit
320ab8172e
|
@ -24,11 +24,17 @@ def test_overflow():
|
||||||
|
|
||||||
|
|
||||||
def test_tobytes():
|
def test_tobytes():
|
||||||
|
# Note that this image triggers the decompression bomb warning:
|
||||||
|
max_pixels = Image.MAX_IMAGE_PIXELS
|
||||||
|
Image.MAX_IMAGE_PIXELS = None
|
||||||
|
|
||||||
# Previously raised an access violation on Windows
|
# Previously raised an access violation on Windows
|
||||||
with Image.open("Tests/images/l2rgb_read.bmp") as im:
|
with Image.open("Tests/images/l2rgb_read.bmp") as im:
|
||||||
with pytest.raises((ValueError, MemoryError, OSError)):
|
with pytest.raises((ValueError, MemoryError, OSError)):
|
||||||
im.tobytes()
|
im.tobytes()
|
||||||
|
|
||||||
|
Image.MAX_IMAGE_PIXELS = max_pixels
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(sys.maxsize <= 2 ** 32, reason="Requires 64-bit system")
|
@pytest.mark.skipif(sys.maxsize <= 2 ** 32, reason="Requires 64-bit system")
|
||||||
def test_ysize():
|
def test_ysize():
|
||||||
|
|
Loading…
Reference in New Issue
Block a user