Merge pull request #4966 from radarhere/decompression

This commit is contained in:
Hugo van Kemenade 2020-10-12 12:13:07 +03:00 committed by GitHub
commit fee6bafead
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 12 deletions

View File

@ -60,6 +60,10 @@ class TestDecompressionBomb:
with pytest.raises(Image.DecompressionBombError):
Image.open("Tests/images/decompression_bomb.gif")
def test_exception_bmp(self):
with pytest.raises(Image.DecompressionBombError):
Image.open("Tests/images/bmp/b/reallybig.bmp")
class TestDecompressionCrop:
@classmethod

View File

@ -86,15 +86,11 @@ A new method :py:meth:`.ImageDraw.regular_polygon`, draws a regular polygon of `
For example ``draw.regular_polygon(((100, 100), 50), 5)``
draws a pentagon centered at the point ``(100, 100)`` with a polygon radius of ``50``.
Security
========
TODO
Other Changes
=============
TODO
^^^^
Error for large BMP files
^^^^^^^^^^^^^^^^^^^^^^^^^
TODO
Previously, if a BMP file was too large, an ``OSError`` would be raised. Now,
``DecompressionBombError`` is used instead, as Pillow already uses for other formats.

View File

@ -162,10 +162,6 @@ class BmpImageFile(ImageFile.ImageFile):
else (1 << file_info["bits"])
)
# ------------------------------- Check abnormal values for DOS attacks
if file_info["width"] * file_info["height"] > 2 ** 31:
raise OSError("Unsupported BMP Size: (%dx%d)" % self.size)
# ---------------------- Check bit depth for unusual unsupported values
self.mode, raw_mode = BIT2MODE.get(file_info["bits"], (None, None))
if self.mode is None: