Skip to content

Commit 884437f

Browse files
authored
Merge pull request #6402 from radarhere/gif_decompression_bomb
Added GIF decompression bomb check
2 parents 8f35234 + c9f1b35 commit 884437f

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed
368 Bytes
Loading

Tests/test_decompression_bomb.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ def test_exception_gif(self):
6161
with Image.open("Tests/images/decompression_bomb.gif"):
6262
pass
6363

64+
def test_exception_gif_extents(self):
65+
with Image.open("Tests/images/decompression_bomb_extents.gif") as im:
66+
with pytest.raises(Image.DecompressionBombError):
67+
im.seek(1)
68+
6469
def test_exception_bmp(self):
6570
with pytest.raises(Image.DecompressionBombError):
6671
with Image.open("Tests/images/bmp/b/reallybig.bmp"):

src/PIL/GifImagePlugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ def _seek(self, frame, update_image=True):
265265
x1, y1 = x0 + i16(s, 4), y0 + i16(s, 6)
266266
if (x1 > self.size[0] or y1 > self.size[1]) and update_image:
267267
self._size = max(x1, self.size[0]), max(y1, self.size[1])
268+
Image._decompression_bomb_check(self._size)
268269
frame_dispose_extent = x0, y0, x1, y1
269270
flags = s[8]
270271

0 commit comments

Comments
 (0)