Skip to content

Commit

Permalink
Reset fuzzer LOAD_TRUNCATED_IMAGES and filters to allow for random te…
Browse files Browse the repository at this point in the history
…st order
  • Loading branch information
radarhere committed Jun 10, 2021
1 parent d99a6ff commit 41fc391
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions Tests/oss-fuzz/fuzz_font.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def main():
fuzzers.enable_decompressionbomb_error()
atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True)
atheris.Fuzz()
fuzzers.disable_decompressionbomb_error()


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions Tests/oss-fuzz/fuzz_pillow.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def main():
fuzzers.enable_decompressionbomb_error()
atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True)
atheris.Fuzz()
fuzzers.disable_decompressionbomb_error()


if __name__ == "__main__":
Expand Down
5 changes: 5 additions & 0 deletions Tests/oss-fuzz/fuzzers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ def enable_decompressionbomb_error():
warnings.simplefilter("error", Image.DecompressionBombWarning)


def disable_decompressionbomb_error():
ImageFile.LOAD_TRUNCATED_IMAGES = False
warnings.resetwarnings()


def fuzz_image(data):
# This will fail on some images in the corpus, as we have many
# invalid images in the test suite.
Expand Down
2 changes: 2 additions & 0 deletions Tests/oss-fuzz/test_fuzzers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def test_fuzz_images(path):
):
# Known Image.* exceptions
assert True
finally:
fuzzers.disable_decompressionbomb_error()


@pytest.mark.parametrize(
Expand Down

0 comments on commit 41fc391

Please sign in to comment.