From 9c023ef97285571e87c1078889c871d2a5cc59d8 Mon Sep 17 00:00:00 2001 From: davkor Date: Tue, 26 Jan 2021 20:27:39 +0000 Subject: [PATCH] Added a fuzzer for integration with OSS-Fuzz --- tests/fuzzers/fuzz_read.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/fuzzers/fuzz_read.py diff --git a/tests/fuzzers/fuzz_read.py b/tests/fuzzers/fuzz_read.py new file mode 100644 index 000000000..022cf05a1 --- /dev/null +++ b/tests/fuzzers/fuzz_read.py @@ -0,0 +1,26 @@ +#!/usr/bin/python3 +import os +import sys +import atheris + +import imageio + +def TestOneInput(data): + with open("/tmp/img1.file", "wb+") as img1_f: + img1_f.write(data) + try: + imageio.imread("/tmp/img1.file") + except ValueError: + None + except RuntimeError: + None + os.remove("/tmp/img1.file") + + +def main(): + atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True) + atheris.Fuzz() + + +if __name__ == "__main__": + main()