mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-30 01:43:17 +03:00
Merge pull request #5393 from hugovk/test-redos
Add test for CVE-2021-25292 ReDoS
This commit is contained in:
commit
356681faae
|
@ -286,3 +286,13 @@ def test_pdf_append_to_bytesio():
|
||||||
f = io.BytesIO(f.getvalue())
|
f = io.BytesIO(f.getvalue())
|
||||||
im.save(f, format="PDF", append=True)
|
im.save(f, format="PDF", append=True)
|
||||||
assert len(f.getvalue()) > initial_size
|
assert len(f.getvalue()) > initial_size
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.timeout(1)
|
||||||
|
def test_redos():
|
||||||
|
malicious = b" trailer<<>>" + b"\n" * 3456
|
||||||
|
|
||||||
|
# This particular exception isn't relevant here.
|
||||||
|
# The important thing is it doesn't timeout, cause a ReDoS (CVE-2021-25292).
|
||||||
|
with pytest.raises(PdfParser.PdfFormatError):
|
||||||
|
PdfParser.PdfParser(buf=malicious)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user