1#!/usr/bin/env bash 2set -eu 3 4# Copyright 2024 Cosmin Truta 5# Copyright 2017 Glenn Randers-Pehrson 6# Copyright 2016 Google Inc. 7# 8# Licensed under the Apache License, Version 2.0 (the "License"); 9# you may not use this file except in compliance with the License. 10# You may obtain a copy of the License at 11# 12# http://www.apache.org/licenses/LICENSE-2.0 13# 14# Unless required by applicable law or agreed to in writing, software 15# distributed under the License is distributed on an "AS IS" BASIS, 16# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17# See the License for the specific language governing permissions and 18# limitations under the License. 19# 20################################################################################ 21 22# Disable logging via library build configuration control. 23sed -e "s/option STDIO/option STDIO disabled/" \ 24 -e "s/option WARNING /option WARNING disabled/" \ 25 -e "s/option WRITE enables WRITE_INT_FUNCTIONS/option WRITE disabled/" \ 26 scripts/pnglibconf.dfa >scripts/pnglibconf.dfa.tmp 27mv -f scripts/pnglibconf.dfa.tmp scripts/pnglibconf.dfa 28 29# Build the libpng library ("libpng16.la"), excluding the auxiliary tools. 30autoreconf -f -i 31./configure --with-libpng-prefix=OSS_FUZZ_ 32make -j$(nproc) clean 33make -j$(nproc) libpng16.la 34 35# Build libpng_read_fuzzer. 36$CXX $CXXFLAGS -std=c++11 -I. \ 37 $SRC/libpng/contrib/oss-fuzz/libpng_read_fuzzer.cc \ 38 -o $OUT/libpng_read_fuzzer \ 39 -lFuzzingEngine .libs/libpng16.a -lz 40 41# Add seed corpus. 42find $SRC/libpng -name "*.png" | grep -v crashers | \ 43 xargs zip $OUT/libpng_read_fuzzer_seed_corpus.zip 44 45cp $SRC/libpng/contrib/oss-fuzz/*.dict \ 46 $SRC/libpng/contrib/oss-fuzz/*.options \ 47 $OUT/ 48