2
0

fuzz_configfile.py 789 B

123456789101112131415161718192021222324252627282930313233343536
  1. import sys
  2. from io import BytesIO
  3. import atheris
  4. from test_utils import is_expected_exception
  5. with atheris.instrument_imports():
  6. from dulwich.config import ConfigFile
  7. def TestOneInput(data):
  8. try:
  9. ConfigFile.from_file(BytesIO(data))
  10. except ValueError as e:
  11. expected_exceptions = [
  12. "without section",
  13. "invalid variable name",
  14. "expected trailing ]",
  15. "invalid section name",
  16. "Invalid subsection",
  17. "escape character",
  18. "missing end quote",
  19. ]
  20. if is_expected_exception(expected_exceptions, e):
  21. return -1
  22. else:
  23. raise e
  24. def main():
  25. atheris.Setup(sys.argv, TestOneInput)
  26. atheris.Fuzz()
  27. if __name__ == "__main__":
  28. main()