From eb7c59645b30992aa72f0020a7c1c77e7e45c613 Mon Sep 17 00:00:00 2001 From: DavidKorczynski Date: Thu, 19 May 2022 10:12:54 +0100 Subject: [PATCH] bad_example: make fuzz-introspector work and fix build (#7706) * bad_example: make fuzz-introspector work and fix build Makes fuzz-introspector work with the bad_example project. This was brought up as an issue on the fuzz-introspector repo. Ref: https://github.com/ossf/fuzz-introspector/issues/257 * Add license to satisfy OSS-Fuzz * add license to build.sh --- projects/bad_example/bad_example_fuzzer.cc | 11 ++++++++++ projects/bad_example/build.sh | 25 ++++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/projects/bad_example/bad_example_fuzzer.cc b/projects/bad_example/bad_example_fuzzer.cc index 55562a503..c107f645f 100644 --- a/projects/bad_example/bad_example_fuzzer.cc +++ b/projects/bad_example/bad_example_fuzzer.cc @@ -1,6 +1,17 @@ // Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +/* Copyright 2022 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. +*/ #include #include diff --git a/projects/bad_example/build.sh b/projects/bad_example/build.sh index 88a7caad2..de89ff45d 100755 --- a/projects/bad_example/build.sh +++ b/projects/bad_example/build.sh @@ -1,3 +1,18 @@ +# Copyright 2022 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. +# +################################################################################ #!/bin/bash -eu # Testcase 1. Valid fuzzer build. @@ -22,8 +37,8 @@ $CXX $CXXFLAGS -std=c++11 -I. -DINTENTIONAL_STARTUP_CRASH \ $LIB_FUZZING_ENGINE ./libz.a -# The latest two examples won't work for coverage build, bail out. -if [[ $SANITIZER = *coverage* ]]; then +# The latest two examples won't work for coverage or introspector, bail out. +if [[ $SANITIZER = *coverage* || $SANITIZER = *introspector* ]]; then exit 0 fi @@ -35,7 +50,8 @@ export CFLAGS="-O1" export CXXFLAGS_ORIG="$CXXFLAGS" export CXXFLAGS="-O1 -stdlib=libc++" -./configure +# We need to pass static as zlib fails to build shared lib in OSS-Fuzz env. +./configure --static make -j$(nproc) clean make -j$(nproc) all @@ -46,7 +62,8 @@ $CXX -fsanitize=$SANITIZER $CXXFLAGS_ORIG -std=c++11 -I. \ # Testcase 4. Completely ignore the flags provided by OSS-Fuzz. ################################################################################ -./configure +# We need to pass static as zlib fails to build shared lib in OSS-Fuzz env. +./configure --static make -j$(nproc) clean make -j$(nproc) all