diff options
author | Joe Drago <joedrago@gmail.com> | 2020-01-29 15:13:45 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-29 15:13:45 -0800 |
commit | 39e5ab2d6eae9a2939ae38c23f7d7c875cfa4f02 (patch) | |
tree | c108507a1a8f60ebfc5048995a77417d8e7e4b7f /projects | |
parent | 4d5e5016c0aa6fc383922dcd61113122b72b7625 (diff) | |
download | oss-fuzz-39e5ab2d6eae9a2939ae38c23f7d7c875cfa4f02.tar.gz |
libavif support (#3302)
Diffstat (limited to 'projects')
-rw-r--r-- | projects/libavif/Dockerfile | 29 | ||||
-rw-r--r-- | projects/libavif/avif_decode_fuzzer.cc | 65 | ||||
-rw-r--r-- | projects/libavif/avif_decode_seed_corpus.zip | bin | 0 -> 5186 bytes | |||
-rw-r--r-- | projects/libavif/bionic.list | 2 | ||||
-rwxr-xr-x | projects/libavif/build.sh | 36 | ||||
-rw-r--r-- | projects/libavif/nasm_apt.pin | 7 | ||||
-rw-r--r-- | projects/libavif/project.yaml | 2 |
7 files changed, 141 insertions, 0 deletions
diff --git a/projects/libavif/Dockerfile b/projects/libavif/Dockerfile new file mode 100644 index 000000000..a5e48a955 --- /dev/null +++ b/projects/libavif/Dockerfile @@ -0,0 +1,29 @@ +# Copyright 2020 Google Inc. +# +# 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. +# +################################################################################ + +FROM gcr.io/oss-fuzz-base/base-builder +MAINTAINER joedrago@gmail.com + +ADD bionic.list /etc/apt/sources.list.d/bionic.list +ADD nasm_apt.pin /etc/apt/preferences + +RUN apt-get update && \ + apt-get install --no-install-recommends -y curl python3-pip python3-setuptools python3-wheel cmake nasm git && \ + pip3 install meson ninja + +RUN git clone --depth 1 https://github.com/AOMediaCodec/libavif.git libavif +WORKDIR libavif +COPY build.sh avif_decode_fuzzer.cc avif_decode_seed_corpus.zip $SRC/ diff --git a/projects/libavif/avif_decode_fuzzer.cc b/projects/libavif/avif_decode_fuzzer.cc new file mode 100644 index 000000000..57473674d --- /dev/null +++ b/projects/libavif/avif_decode_fuzzer.cc @@ -0,0 +1,65 @@ +// Copyright 2020 Google Inc. +// +// 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. +// +//############################################################################### + +#include "avif/avif.h" + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + avifROData raw; + raw.data = Data; + raw.size = Size; + + avifDecoder *decoder = avifDecoderCreate(); + // avifDecoderSetSource(decoder, AVIF_DECODER_SOURCE_PRIMARY_ITEM); + avifResult result = avifDecoderParse(decoder, &raw); + if (result == AVIF_RESULT_OK) { + // printf("AVIF container reports dimensions: %ux%u (@ %u bpc)\n", + // decoder->containerWidth, decoder->containerHeight, + // decoder->containerDepth); + for (int loop = 0; loop < 2; ++loop) { + // printf("Image decoded: %s\n", inputFilename); + // printf(" * %2.2f seconds, %d images\n", decoder->duration, + // decoder->imageCount); + int frameIndex = 0; + while (avifDecoderNextImage(decoder) == AVIF_RESULT_OK) { + // printf(" * Decoded frame [%d] [pts %2.2f] [duration %2.2f] " + // "[keyframe:%s nearest:%u]: %dx%d\n", + // frameIndex, decoder->imageTiming.pts, + // decoder->imageTiming.duration, + // avifDecoderIsKeyframe(decoder, frameIndex) ? "true" : "false", + // avifDecoderNearestKeyframe(decoder, frameIndex), + // decoder->image->width, decoder->image->height); + ++frameIndex; + } + + if (loop != 1) { + result = avifDecoderReset(decoder); + if (result == AVIF_RESULT_OK) { + // printf("Decoder reset! Decoding one more time.\n"); + } else { + // printf("ERROR: Failed to reset decode: %s\n", + // avifResultToString(result)); + break; + } + } + } + } else { + // printf("ERROR: Failed to decode image: %s\n", + // avifResultToString(result)); + } + + avifDecoderDestroy(decoder); + return 0; // Non-zero return values are reserved for future use. +} diff --git a/projects/libavif/avif_decode_seed_corpus.zip b/projects/libavif/avif_decode_seed_corpus.zip Binary files differnew file mode 100644 index 000000000..eb04c208a --- /dev/null +++ b/projects/libavif/avif_decode_seed_corpus.zip diff --git a/projects/libavif/bionic.list b/projects/libavif/bionic.list new file mode 100644 index 000000000..8621803a7 --- /dev/null +++ b/projects/libavif/bionic.list @@ -0,0 +1,2 @@ +# use nasm 2.13.02 from bionic +deb http://archive.ubuntu.com/ubuntu/ bionic universe diff --git a/projects/libavif/build.sh b/projects/libavif/build.sh new file mode 100755 index 000000000..bf2bf4cf6 --- /dev/null +++ b/projects/libavif/build.sh @@ -0,0 +1,36 @@ +#!/bin/bash -eu +# Copyright 2020 Google Inc. +# +# 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. +# +################################################################################ + +# build dav1d +cd ext && bash dav1d.cmd && cd .. + +# build libavif +mkdir build +cd build +cmake -G Ninja -DBUILD_SHARED_LIBS=0 -DAVIF_CODEC_DAV1D=1 -DAVIF_LOCAL_DAV1D=1 .. +ninja + +# build fuzzer +$CXX $CXXFLAGS -std=c++11 -I../include \ + $SRC/avif_decode_fuzzer.cc -o $OUT/avif_decode_fuzzer \ + $LIB_FUZZING_ENGINE libavif.a ../ext/dav1d/build/src/libdav1d.a + +# copy seed corpus +cp $SRC/avif_decode_seed_corpus.zip $OUT/ + +# show contents of $OUT/ for sanity checking +find $OUT/ diff --git a/projects/libavif/nasm_apt.pin b/projects/libavif/nasm_apt.pin new file mode 100644 index 000000000..69099026b --- /dev/null +++ b/projects/libavif/nasm_apt.pin @@ -0,0 +1,7 @@ +Package: * +Pin: release n=bionic +Pin-Priority: 1 + +Package: nasm +Pin: release n=bionic +Pin-Priority: 555 diff --git a/projects/libavif/project.yaml b/projects/libavif/project.yaml new file mode 100644 index 000000000..60816faf5 --- /dev/null +++ b/projects/libavif/project.yaml @@ -0,0 +1,2 @@ +homepage: "https://github.com/AOMediaCodec/libavif" +primary_contact: "joedrago@gmail.com" |