iniconfig: fix fuzzer (#8146)

The file operations had issues with file not found. This will trigger the same parsing routines but without file operations.

Fixes: https://github.com/pytest-dev/iniconfig/issues/41
This commit is contained in:
DavidKorczynski 2022-08-04 13:34:09 +01:00 committed by GitHub
parent 6b6fff7407
commit 73371ad324
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -21,13 +21,12 @@ import iniconfig
def TestOneInput(data):
"""Simple fuzzer that targets parse routine"""
with open("example.ini", "wb") as f:
f.write(data)
fdp = atheris.FuzzedDataProvider(data)
try:
ini = iniconfig.IniConfig("example.ini")
except (iniconfig.ParseError, UnicodeDecodeError) as e:
ini = iniconfig.IniConfig(None, fdp.ConsumeUnicodeNoSurrogates(sys.maxsize))
except iniconfig.ParseError:
pass
os.remove("example.ini")
def main():
atheris.instrument_all()