Skip to content

Commit 38be37c

Browse files
authored
Merge branch 'main' into docs-link-exceptions
2 parents ca74a5e + bee9c59 commit 38be37c

File tree

6 files changed

+30
-11
lines changed

6 files changed

+30
-11
lines changed

.github/workflows/test-docker.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ jobs:
5151
debian-11-bullseye-amd64,
5252
debian-12-bookworm-x86,
5353
debian-12-bookworm-amd64,
54-
fedora-37-amd64,
5554
fedora-38-amd64,
5655
gentoo,
5756
ubuntu-20.04-focal-amd64,

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Changelog (Pillow)
33
==================
44

5+
10.2.0 (unreleased)
6+
-------------------
7+
8+
- Fixed frombytes() for images with a zero dimension #7493
9+
[radarhere]
10+
511
10.1.0 (2023-10-15)
612
-------------------
713

Tests/test_image.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,13 @@ def test_zero_tobytes(self, size):
906906
im = Image.new("RGB", size)
907907
assert im.tobytes() == b""
908908

909+
@pytest.mark.parametrize("size", ((1, 0), (0, 1), (0, 0)))
910+
def test_zero_frombytes(self, size):
911+
Image.frombytes("RGB", size, b"")
912+
913+
im = Image.new("RGB", size)
914+
im.frombytes(b"")
915+
909916
def test_has_transparency_data(self):
910917
for mode in ("1", "L", "P", "RGB"):
911918
im = Image.new(mode, (1, 1))

docs/installation.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ Install Pillow with :command:`pip`::
4242
python3 -m pip install --upgrade pip
4343
python3 -m pip install --upgrade Pillow
4444

45+
Optionally, install :pypi:`defusedxml` for Pillow to read XMP data,
46+
and :pypi:`olefile` for Pillow to read FPX and MIC images::
47+
48+
python3 -m pip install --upgrade defusedxml olefile
49+
4550

4651
.. tab:: Linux
4752

@@ -456,8 +461,6 @@ These platforms are built and tested for every change.
456461
+----------------------------------+----------------------------+---------------------+
457462
| Debian 12 Bookworm | 3.11 | x86, x86-64 |
458463
+----------------------------------+----------------------------+---------------------+
459-
| Fedora 37 | 3.11 | x86-64 |
460-
+----------------------------------+----------------------------+---------------------+
461464
| Fedora 38 | 3.11 | x86-64 |
462465
+----------------------------------+----------------------------+---------------------+
463466
| Gentoo | 3.9 | x86-64 |

docs/releasenotes/10.0.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ been processed before Pillow started checking for decompression bombs.
173173
Added ImageFont.MAX_STRING_LENGTH
174174
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
175175

176-
To protect against potential DOS attacks when using arbitrary strings as text
176+
:cve:`2023-44271`: To protect against potential DOS attacks when using arbitrary strings as text
177177
input, Pillow will now raise a :py:exc:`ValueError` if the number of characters
178178
passed into ImageFont methods is over a certain limit,
179179
:py:data:`PIL.ImageFont.MAX_STRING_LENGTH`.

src/PIL/Image.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,9 @@ def frombytes(self, data, decoder_name="raw", *args):
791791
but loads data into this image instead of creating a new image object.
792792
"""
793793

794+
if self.width == 0 or self.height == 0:
795+
return
796+
794797
# may pass tuple instead of argument list
795798
if len(args) == 1 and isinstance(args[0], tuple):
796799
args = args[0]
@@ -2967,15 +2970,16 @@ def frombytes(mode, size, data, decoder_name="raw", *args):
29672970

29682971
_check_size(size)
29692972

2970-
# may pass tuple instead of argument list
2971-
if len(args) == 1 and isinstance(args[0], tuple):
2972-
args = args[0]
2973+
im = new(mode, size)
2974+
if im.width != 0 and im.height != 0:
2975+
# may pass tuple instead of argument list
2976+
if len(args) == 1 and isinstance(args[0], tuple):
2977+
args = args[0]
29732978

2974-
if decoder_name == "raw" and args == ():
2975-
args = mode
2979+
if decoder_name == "raw" and args == ():
2980+
args = mode
29762981

2977-
im = new(mode, size)
2978-
im.frombytes(data, decoder_name, args)
2982+
im.frombytes(data, decoder_name, args)
29792983
return im
29802984

29812985

0 commit comments

Comments
 (0)