mirror of https://github.com/google/oss-fuzz.git
54 lines
46 KiB
Python
54 lines
46 KiB
Python
![]() |
#!/usr/bin/python3
|
||
|
|
||
|
# Copyright 2020 Google LLC
|
||
|
#
|
||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
# you may not use this file except in compliance with the License.
|
||
|
# You may obtain a copy of the License at
|
||
|
#
|
||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||
|
#
|
||
|
# Unless required by applicable law or agreed to in writing, software
|
||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
# See the License for the specific language governing permissions and
|
||
|
# limitations under the License.
|
||
|
|
||
|
import atheris
|
||
|
import sys
|
||
|
import os
|
||
|
import io
|
||
|
import warnings
|
||
|
from PIL import Image, ImageFile
|
||
|
|
||
|
encoded=b"\xff\xd8\xff\xe0\x00\x10\x4a\x46\x49\x46\x00\x01\x01\x00\x00\x01\x00\x01\x00\x00\xff\xdb\x00\x43\x00\x08\x06\x06\x07\x06\x05\x08\x07\x07\x07\x09\x09\x08\x0a\x0c\x14\x0d\x0c\x0b\x0b\x0c\x19\x12\x13\x0f\x14\x1d\x1a\x1f\x1e\x1d\x1a\x1c\x1c\x20\x24\x2e\x27\x20\x22\x2c\x23\x1c\x1c\x28\x37\x29\x2c\x30\x31\x34\x34\x34\x1f\x27\x39\x3d\x38\x32\x3c\x2e\x33\x34\x32\xff\xdb\x00\x43\x01\x09\x09\x09\x0c\x0b\x0c\x18\x0d\x0d\x18\x32\x21\x1c\x21\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\x32\xff\xc0\x00\x11\x08\x01\x00\x02\x00\x03\x01\x22\x00\x02\x11\x01\x03\x11\x01\xff\xc4\x00\x1f\x00\x00\x01\x05\x01\x01\x01\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\xff\xc4\x00\xb5\x10\x00\x02\x01\x03\x03\x02\x04\x03\x05\x05\x04\x04\x00\x00\x01\x7d\x01\x02\x03\x00\x04\x11\x05\x12\x21\x31\x41\x06\x13\x51\x61\x07\x22\x71\x14\x32\x81\x91\xa1\x08\x23\x42\xb1\xc1\x15\x52\xd1\xf0\x24\x33\x62\x72\x82\x09\x0a\x16\x17\x18\x19\x1a\x25\x26\x27\x28\x29\x2a\x34\x35\x36\x37\x38\x39\x3a\x43\x44\x45\x46\x47\x48\x49\x4a\x53\x54\x55\x56\x57\x58\x59\x5a\x63\x64\x65\x66\x67\x68\x69\x6a\x73\x74\x75\x76\x77\x78\x79\x7a\x83\x84\x85\x86\x87\x88\x89\x8a\x92\x93\x94\x95\x96\x97\x98\x99\x9a\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xff\xc4\x00\x1f\x01\x00\x03\x01\x01\x01\x01\x01\x01\x01\x01\x01\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\xff\xc4\x00\xb5\x11\x00\x02\x01\x02\x04\x04\x03\x04\x07\x05\x04\x04\x00\x01\x02\x77\x00\x01\x02\x03\x11\x04\x05\x21\x31\x06\x12\x41\x51\x07\x61\x71\x13\x22\x32\x81\x08\x14\x42\x91\xa1\xb1\xc1\x09\x23\x33\x52\xf0\x15\x62\x72\xd1\x0a\x16\x24\x34\xe1\x25\xf1\x17\x18\x19\x1a\x26\x27\x28\x29\x2a\x35\x36\x37\x38\x39\x3a\x43\x44\x45\x46\x47\x48\x49\x4a\x53\x54\x55\x56\x57\x58\x59\x5a\x63\x64\x65\x66\x67\x68\x69\x6a\x73\x74\x75\x76\x77\x78\x79\x7a\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x92\x93\x94\x95\x96\x97\x98\x99\x9a\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xff\xda\x00\x0c\x03\x01\x00\x02\x11\x03\x11\x00\x3f\x00\xf9\xfe\x8a\x28\xa0\x02\x8a\x28\xa0\x02\x8a\x28\xa0\x02\x8a\x28\xa0\x02\x8a\x28\xa0\x02\x8a\x28\xa0\x02\x8a\x28\xa0\x02\x8a\x28\xa0\x02\x8a\x28\xa0\x02\x8a\x28\xa0\x02\x8a\x28\xa0\x02\x8a\x28\xa0\x02\x8a\x28\xa0\x02\x8a\x28\xa0\x02\x8a\x28\xa0\x02\x8a\x28\xa0\x0d\x7c\x66\x55\xa5\x94\xfc\xca\x29\x63\x52\x5c\x1c\x1c\x0a\x6c\xa7\xf7\x8b\x5e\x8c\xb5\x57\x20\x9a\x63\xf2\xad\x03\x96\x14\x92\x9c\xaa\xd2\xf4\x22\xb7\xbf\x33\xb0\x87\x4a\x49\x8e\xa1\x8f\x86\x15\x34\xbc\x43\x55\xd4\x9a\x96\xdb\x90\x89\x9f\x87\x00\xf2\x7d\x6b\xd0\xbc\x31\xe2\x61\xa4\x78\x65\x34\xeb\x53\xfe\x91\x74\xc0\x37\xe0\x6b\xce\xdc\xfc\xa0\x2f\x3e\xf5\x7b\x43\x62\x75\x8b\x53\x9f\x94\x37\x15\x96\x2e\x37\x89\xa5\x27\xa9\xdd\x78\xc3\xc5\x5a\x96\x9b\xac\xcb\x64\x25\x0d\x6a\xe8\xbb\xa2\xc7\xb7\xad\x79\xe4\xc5\x5c\x33\x28\xd8\x99\xce\xca\xe9\x7c\x7f\x8f\xf8\x4a\x25\xe3\xef\x2a\xe3\xf2\xae\x65\xf9\x75\x1f\x7b\x91\xf2\xd7\x26\x01\x2f\xab\xf3\x5b\x74\x6b\x88\x77\xad\xf3\x3b\x1f\x11\x62\x3f\x01\xe8\xea\x3e\x60\x43\x7f\x3a\xab\xe1\x4f\x1e\x6a\xbe\x17\xda\xb0\x3f\x99\x07\x74\xc6\x2a\xd7\x8c\xc8\x4f\x0e\x68\x68\x57\x0c\x15\xb8\xae\x4e\xca\xce\xe2\xfa\x64\x82\xd9\x19\xe6\x90\xe0\x05\x19\xc5\x46\x5e\xa1\xec\x39\x9f\x56\x56\x25\xda\xb7\xc8\xfa\x9b\xc3\x1e\x30\x87\x5c\xf0\xaa\x6b\x57\x88\x2d\xe3\xfe\x32\x4f\x4a\xf3\x7f\x8c\x17\xda\x6d\xfc\x16\x17\xf6\x77\xea\xee\x84\xed\x8c\x0c\xee\xff\x00\x0a\xb9\x37\x85\x35\xc8\xfe\x17\xdb\x58\xdc\x31\xb0\x8a\x25\x66\xb8\x00\xe7\x77\x39\x15\xe6\x3e\x12\xd0\x2d\x35\x6d\x45\x9b\x56\xd4\x1a\xde\xc6\x36\xc1\x62\x0b\x6e\xe7\xd2\xa6\x29\x41\xf3\x22\x1f\x2c\xb4\x63\xd3\x5f\x92\x66\x58\xe3\xb4\
|
||
|
|
||
|
is_init = True
|
||
|
def TestOneInput(data):
|
||
|
global is_init
|
||
|
# We need to write a jpeg file first because otherwise
|
||
|
# libFuzzer will complain that no coverage exists and exit.
|
||
|
if is_init:
|
||
|
target_data = encoded
|
||
|
is_init = False
|
||
|
else:
|
||
|
target_data = data
|
||
|
try:
|
||
|
im = Image.open(io.BytesIO(target_data))
|
||
|
im.save(io.BytesIO(), "BMP")
|
||
|
except Exception:
|
||
|
# We're catching all exceptions because Pillow's exceptions are
|
||
|
# directly inheriting from Exception.
|
||
|
return
|
||
|
return
|
||
|
|
||
|
def main():
|
||
|
ImageFile.LOAD_TRUNCATED_IMAGES = True
|
||
|
warnings.filterwarnings("ignore")
|
||
|
atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=False)
|
||
|
atheris.Fuzz()
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
main()
|
||
|
|