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