mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-09-24 13:07:00 +03:00
Limit length of read operation
This commit is contained in:
parent
57a5f76e6d
commit
485d9884cf
|
@ -492,6 +492,11 @@ def test_stroke_mask() -> None:
|
|||
assert mask.getpixel((42, 5)) == 255
|
||||
|
||||
|
||||
def test_load_invalid_file() -> None:
|
||||
with pytest.raises(SyntaxError, match="Not a PILfont file"):
|
||||
ImageFont.load("Tests/images/1_trns.png")
|
||||
|
||||
|
||||
def test_load_when_image_not_found() -> None:
|
||||
with tempfile.NamedTemporaryFile(delete=False) as tmp:
|
||||
pass
|
||||
|
|
|
@ -126,7 +126,7 @@ class ImageFont:
|
|||
|
||||
def _load_pilfont_data(self, file: IO[bytes], image: Image.Image) -> None:
|
||||
# read PILfont header
|
||||
if file.readline() != b"PILfont\n":
|
||||
if file.read(8) != b"PILfont\n":
|
||||
msg = "Not a PILfont file"
|
||||
raise SyntaxError(msg)
|
||||
file.readline()
|
||||
|
|
Loading…
Reference in New Issue
Block a user