From 320ab8172e0d45b57a01c21cb0905abdf8593849 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Tue, 24 Aug 2021 11:19:45 +0300 Subject: [PATCH] Avoid DecompressionBombWarning: Image size (151587072 pixels) exceeds limit of 89478485 pixels, could be decompression bomb DOS attack. --- Tests/test_map.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Tests/test_map.py b/Tests/test_map.py index 752c5f268..42f3447eb 100644 --- a/Tests/test_map.py +++ b/Tests/test_map.py @@ -24,11 +24,17 @@ def test_overflow(): 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 with Image.open("Tests/images/l2rgb_read.bmp") as im: with pytest.raises((ValueError, MemoryError, OSError)): im.tobytes() + Image.MAX_IMAGE_PIXELS = max_pixels + @pytest.mark.skipif(sys.maxsize <= 2 ** 32, reason="Requires 64-bit system") def test_ysize():