From 84d255ab00727c83407d6c0c0421159024010360 Mon Sep 17 00:00:00 2001 From: DavidKorczynski Date: Sat, 21 May 2022 13:34:16 +0100 Subject: [PATCH] libprotobuf-mutator projects: fix builds (#7737) * libprotobuf-mutator projects: fix builds Ref: https://github.com/google/oss-fuzz/issues/7736 * boringssl: fix libprotobuf-mutator fuzzer * giflib: fix libprotobuf-mutator fuzzer * jsoncpp: fix libprotobuf-mutator fuzzer * xerces-c: fix libprotobuf-mutator fuzzer * libpng-proto: fix libprotobuf-mutator fuzzer * giflib: add license header to satisfy CI --- projects/boringssl/build.sh | 1 + projects/giflib/build.sh | 20 ++++++++++++++++++-- projects/jsoncpp/build.sh | 4 ++-- projects/libpng-proto/build.sh | 4 ++-- projects/nginx/make_fuzzers | 2 +- projects/xerces-c/build.sh | 2 +- 6 files changed, 25 insertions(+), 8 deletions(-) diff --git a/projects/boringssl/build.sh b/projects/boringssl/build.sh index cb5eaa238..b52431359 100755 --- a/projects/boringssl/build.sh +++ b/projects/boringssl/build.sh @@ -61,6 +61,7 @@ if [[ $CFLAGS != *sanitize=memory* ]]; then fuzzerName=$(basename $fuzzerName .cc) echo "Building fuzzer $fuzzerName" $CXX $CXXFLAGS -I genfiles -I . -I $SRC/libprotobuf-mutator/ -I $SRC/LPM/external.protobuf/include -I include $LIB_FUZZING_ENGINE \ + -DNDEBUG \ -I $SRC/boringssl/include \ $F genfiles/asn1_pdu.pb.cc $SRC/asn1_pdu_to_der.cc $SRC/common.cc \ ./ssl/libssl.a ./crypto/libcrypto.a \ diff --git a/projects/giflib/build.sh b/projects/giflib/build.sh index 97b967e98..b5d9a0413 100755 --- a/projects/giflib/build.sh +++ b/projects/giflib/build.sh @@ -1,3 +1,19 @@ +# 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. +# +################################################################################ + set -e SOURCES=(dgif_lib.c egif_lib.c getarg.c gifalloc.c gif_err.c gif_font.c \ gif_hash.c openbsd-reallocarray.c qprintf.c quantize.c) @@ -21,12 +37,12 @@ $CXX $CXXFLAGS $LIB_FUZZING_ENGINE -std=c++11 -I giflib-code egif_fuzz_common.c rm -rf genfiles && mkdir genfiles && LPM/external.protobuf/bin/protoc gif_fuzz_proto.proto --cpp_out=genfiles -$CXX $CXXFLAGS -Wall -c -I giflib-code dgif_protobuf_target.cc -I libprotobuf-mutator/ \ +$CXX $CXXFLAGS -DNDEBUG -Wall -c -I giflib-code dgif_protobuf_target.cc -I libprotobuf-mutator/ \ -I genfiles \ -I LPM/external.protobuf/include \ -o dgif_protobuf_target.o -$CXX $CXXFLAGS $LIB_FUZZING_ENGINE -std=c++11 -I. -I giflib-code dgif_protobuf_target.o dgif_fuzz_common.cc genfiles/gif_fuzz_proto.pb.cc \ +$CXX $CXXFLAGS $LIB_FUZZING_ENGINE -DNDEBUG -std=c++11 -I. -I giflib-code dgif_protobuf_target.o dgif_fuzz_common.cc genfiles/gif_fuzz_proto.pb.cc \ ProtoToGif.cpp \ -I LPM/external.protobuf/include \ -I genfiles \ diff --git a/projects/jsoncpp/build.sh b/projects/jsoncpp/build.sh index 739dcd8ba..6aee34f82 100644 --- a/projects/jsoncpp/build.sh +++ b/projects/jsoncpp/build.sh @@ -34,11 +34,11 @@ if [[ $CFLAGS != *sanitize=memory* ]]; then rm -rf genfiles && mkdir genfiles && ../LPM/external.protobuf/bin/protoc json.proto --cpp_out=genfiles --proto_path=$SRC # Compile LPM fuzzer. -$CXX $CXXFLAGS -I genfiles -I .. -I ../libprotobuf-mutator/ -I ../LPM/external.protobuf/include -I ../include $LIB_FUZZING_ENGINE \ +$CXX $CXXFLAGS -DNDEBUG -I genfiles -I .. -I ../libprotobuf-mutator/ -I ../LPM/external.protobuf/include -I ../include $LIB_FUZZING_ENGINE \ $SRC/jsoncpp_fuzz_proto.cc genfiles/json.pb.cc $SRC/json_proto_converter.cc \ ../LPM/src/libfuzzer/libprotobuf-mutator-libfuzzer.a \ ../LPM/src/libprotobuf-mutator.a \ ../LPM/external.protobuf/lib/libprotobuf.a \ -o $OUT/jsoncpp_proto_fuzzer \ lib/libjsoncpp.a -fi \ No newline at end of file +fi diff --git a/projects/libpng-proto/build.sh b/projects/libpng-proto/build.sh index b51c9f9b8..75984f57b 100755 --- a/projects/libpng-proto/build.sh +++ b/projects/libpng-proto/build.sh @@ -32,7 +32,7 @@ rm -rf genfiles && mkdir genfiles && LPM/external.protobuf/bin/protoc png_fuzz_p $CXX $CXXFLAGS -c -DLLVMFuzzerTestOneInput=FuzzPNG libpng/contrib/oss-fuzz/libpng_read_fuzzer.cc -I libpng # compile & link the rest -$CXX $CXXFLAGS png_proto_fuzzer_example.cc libpng_read_fuzzer.o genfiles/png_fuzz_proto.pb.cc \ +$CXX $CXXFLAGS -DNDEBUG png_proto_fuzzer_example.cc libpng_read_fuzzer.o genfiles/png_fuzz_proto.pb.cc \ -I genfiles -I. -I libprotobuf-mutator/ -I LPM/external.protobuf/include \ -lz \ LPM/src/libfuzzer/libprotobuf-mutator-libfuzzer.a \ @@ -43,7 +43,7 @@ $CXX $CXXFLAGS png_proto_fuzzer_example.cc libpng_read_fuzzer.o genfiles/png_fuz -o $OUT/png_proto_fuzzer_example # custom png proto mutator -$CXX $CXXFLAGS png_proto_fuzzer_example.cc png_proto_mutator.cc libpng_read_fuzzer.o genfiles/png_fuzz_proto.pb.cc \ +$CXX $CXXFLAGS -DNDEBUG png_proto_fuzzer_example.cc png_proto_mutator.cc libpng_read_fuzzer.o genfiles/png_fuzz_proto.pb.cc \ -I genfiles -I. -I libprotobuf-mutator/ -I LPM/external.protobuf/include \ -lz \ LPM/src/libfuzzer/libprotobuf-mutator-libfuzzer.a \ diff --git a/projects/nginx/make_fuzzers b/projects/nginx/make_fuzzers index a62d4d6ec..37427ae90 100644 --- a/projects/nginx/make_fuzzers +++ b/projects/nginx/make_fuzzers @@ -22,7 +22,7 @@ objs/src/fuzz/wrappers.o: \$(CC) $ngx_compile_opt \$(CFLAGS) -o objs/src/fuzz/wrappers.o src/fuzz/wrappers.c objs/http_request_fuzzer: $ngx_deps_fuzz - \$(CXX) \$(CXXFLAGS) src/fuzz/http_request_fuzzer.cc \ + \$(CXX) \$(CXXFLAGS) -DNDEBUG src/fuzz/http_request_fuzzer.cc \ src/fuzz/genfiles/http_request_proto.pb.cc \ -o objs/http_request_fuzzer \ \$(CORE_INCS) \$(HTTP_INCS) \ diff --git a/projects/xerces-c/build.sh b/projects/xerces-c/build.sh index 992fc3f58..a3740d442 100755 --- a/projects/xerces-c/build.sh +++ b/projects/xerces-c/build.sh @@ -28,7 +28,7 @@ $CXX $CXXFLAGS $LIB_FUZZING_ENGINE -std=c++11 \ if [[ $CFLAGS != *sanitize=memory* ]]; then rm -rf genfiles && mkdir genfiles && LPM/external.protobuf/bin/protoc xml.proto --cpp_out=genfiles - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE -std=c++11 \ + $CXX $CXXFLAGS $LIB_FUZZING_ENGINE -DNDEBUG -std=c++11 \ -I. -I xerces-c/src -Ixerces-c/build/src genfiles/xml.pb.cc xmlProtoConverter.cpp xerces_fuzz_common.cpp parse_target_proto.cpp \ -I libprotobuf-mutator/ \ -I genfiles \