Skip to content

Commit

Permalink
Add Exiv2 (#6186)
Browse files Browse the repository at this point in the history
* Add Exiv2.

* Remove sanitizer flags so that OSS-Fuzz can insert its own.

* Using the fuzzer to create the seed corpus doesn't work with AFL.

* Only use libFuzzer

* Don't add files over 20KB to the corpus.

* Use ${LIB_FUZZING_ENGINE} when building the fuzz target.
  • Loading branch information
kevinbackhouse authored Aug 17, 2021
1 parent a4bc239 commit c0b2a00
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
22 changes: 22 additions & 0 deletions projects/exiv2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2021 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.
#
################################################################################
FROM gcr.io/oss-fuzz-base/base-builder

RUN apt-get update && apt-get install -y cmake make ccache python3 libexpat1-dev zlib1g-dev libssh-dev libcurl4-openssl-dev libxml2-utils
RUN git clone https://github.com/Exiv2/exiv2 exiv2
WORKDIR exiv2

COPY build.sh $SRC/
35 changes: 35 additions & 0 deletions projects/exiv2/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash -eu
# Copyright 2021 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.
#
################################################################################

pwd
mkdir -p build
cd build
cmake -DEXIV2_ENABLE_PNG=ON -DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_ENABLE_CURL=OFF -DEXIV2_ENABLE_BMFF=ON -DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_COMPILER="${CXX}" -DCMAKE_CXX_FLAGS="${CXXFLAGS}" -DEXIV2_BUILD_FUZZ_TESTS=ON -DEXIV2_TEAM_OSS_FUZZ=ON -DLIB_FUZZING_ENGINE="${LIB_FUZZING_ENGINE}" ..
make -j $(nproc)

# Copy binary and dictionary to $OUT
cp ./bin/fuzz-read-print-write $OUT
cp ../fuzz/exiv2.dict $OUT/fuzz-read-print-write.dict

# Initialize the corpus, using the files in test/data
mkdir corpus
for f in $(find ../test/data -type f -size -20k); do
s=$(sha1sum "$f" | awk '{print $1}')
cp $f corpus/$s
done

zip -j $OUT/fuzz-read-print-write.zip corpus/*
9 changes: 9 additions & 0 deletions projects/exiv2/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
homepage: "https://www.exiv2.org"
language: c++
primary_contact: "[email protected]"
sanitizers:
- address
- undefined
architectures:
- x86_64
main_repo: 'https://github.com/Exiv2/exiv2'

0 comments on commit c0b2a00

Please sign in to comment.