summaryrefslogtreecommitdiff
path: root/src/lxml/tests/fuzz_xml_parse.py
blob: 980d8d0b89b42dcdb6dbadcd58c9d00e0497bcc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""
Fuzzes the lxml.etree.XML function with the Atheris fuzzer.

The goal is to catch unhandled exceptions and potential 
memory corruption issues in auto-generated code.
"""

import atheris
import sys

from lxml import etree


def test_etree_xml(data):
    fdp = atheris.FuzzedDataProvider(data)
    try:
        etree.XML(fdp.ConsumeUnicode(sys.maxsize))
    except etree.XMLSyntaxError:
        pass
    return


if __name__ == "__main__":
    atheris.Setup(sys.argv, test_etree_xml, enable_python_coverage=True)
    atheris.Fuzz()