Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed OSError in favour of DecompressionBombError for BMP #4966

Merged
merged 2 commits into from Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions Tests/test_decompression_bomb.py
Expand Up @@ -60,6 +60,10 @@ def test_exception_gif(self):
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
Expand Down
12 changes: 4 additions & 8 deletions docs/releasenotes/8.0.0.rst
Expand Up @@ -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.
4 changes: 0 additions & 4 deletions src/PIL/BmpImagePlugin.py
Expand Up @@ -162,10 +162,6 @@ def _bitmap(self, header=0, offset=0):
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:
Expand Down