This commit is contained in:
Eric Soroos 2021-01-07 13:07:28 +01:00
parent ffbaa6523d
commit 37a7c601cc
2 changed files with 15 additions and 9 deletions

View File

@ -14,13 +14,16 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import atheris_no_libfuzzer as atheris
import sys
import os
import io import io
import os
import sys
import warnings import warnings
import atheris_no_libfuzzer as atheris
from PIL import Image, ImageFile, ImageFilter from PIL import Image, ImageFile, ImageFilter
def TestOneInput(data): def TestOneInput(data):
try: try:
with Image.open(io.BytesIO(data)) as im: with Image.open(io.BytesIO(data)) as im:
@ -33,13 +36,14 @@ def TestOneInput(data):
return return
return return
def main(): def main():
ImageFile.LOAD_TRUNCATED_IMAGES = True ImageFile.LOAD_TRUNCATED_IMAGES = True
warnings.filterwarnings("ignore") warnings.filterwarnings("ignore")
warnings.simplefilter('error', Image.DecompressionBombWarning) warnings.simplefilter("error", Image.DecompressionBombWarning)
atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True) atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True)
atheris.Fuzz() atheris.Fuzz()
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@ -840,7 +840,9 @@ class pil_build_ext(build_ext):
def debug_build(): def debug_build():
return hasattr(sys, "gettotalrefcount") or os.environ.get("LIB_FUZZING_ENGINE", None) return hasattr(sys, "gettotalrefcount") or os.environ.get(
"LIB_FUZZING_ENGINE", None
)
files = ["src/_imaging.c"] files = ["src/_imaging.c"]