File CVE-2022-45198.patch of Package python-Pillow.18518
Index: Pillow-8.4.0/Tests/test_decompression_bomb.py
===================================================================
--- Pillow-8.4.0.orig/Tests/test_decompression_bomb.py
+++ Pillow-8.4.0/Tests/test_decompression_bomb.py
@@ -62,6 +62,11 @@ class TestDecompressionBomb:
with Image.open("Tests/images/decompression_bomb.gif"):
pass
+ def test_exception_gif_extents(self):
+ with Image.open("Tests/images/decompression_bomb_extents.gif") as im:
+ with pytest.raises(Image.DecompressionBombError):
+ im.seek(1)
+
def test_exception_bmp(self):
with pytest.raises(Image.DecompressionBombError):
with Image.open("Tests/images/bmp/b/reallybig.bmp"):
Index: Pillow-8.4.0/src/PIL/GifImagePlugin.py
===================================================================
--- Pillow-8.4.0.orig/src/PIL/GifImagePlugin.py
+++ Pillow-8.4.0/src/PIL/GifImagePlugin.py
@@ -239,6 +239,7 @@ class GifImageFile(ImageFile.ImageFile):
x1, y1 = x0 + i16(s, 4), y0 + i16(s, 6)
if x1 > self.size[0] or y1 > self.size[1]:
self._size = max(x1, self.size[0]), max(y1, self.size[1])
+ Image._decompression_bomb_check(self._size)
self.dispose_extent = x0, y0, x1, y1
flags = s[8]