From a78e8624c9018b26a52a17c9f3044c4b22a06d8d Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Wed, 28 Aug 2019 14:12:56 +0200 Subject: [PATCH 1/8] Changes: Document #308 --- expat/Changes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/expat/Changes b/expat/Changes index 74b4806e..afc16e05 100644 --- a/expat/Changes +++ b/expat/Changes @@ -29,6 +29,7 @@ Release x.x.x xxx xxx xx xxxx Old: expat[d].lib New: expat[w][d].lib CMake: Migrate files from Windows to Unix line endings + #308 CMake: Integrate OSS-Fuzz fuzzers #299 #302 Windows: Replace LoadLibrary hack to access unofficial API function SystemFunction036 (RtlGenRandom) by using official API function rand_s (needs WinXP+) @@ -45,6 +46,7 @@ Release x.x.x xxx xxx xx xxxx Khajapasha Mohammed Kishore Kunche Marco Maggi + Mitch Phillips Rolf Ade xantares From 22e8631be67587ec1170b60afaece69b31b44c98 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Wed, 28 Aug 2019 14:15:54 +0200 Subject: [PATCH 2/8] CMake: Add BUILD_fuzzers to summary --- expat/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/expat/CMakeLists.txt b/expat/CMakeLists.txt index 546be104..502b876c 100644 --- a/expat/CMakeLists.txt +++ b/expat/CMakeLists.txt @@ -388,6 +388,7 @@ endif() message(STATUS "") message(STATUS " Build documentation ........ ${BUILD_doc}") message(STATUS " Build examples ............. ${BUILD_examples}") +message(STATUS " Build fuzzers .............. ${BUILD_fuzzers}") message(STATUS " Build tests ................ ${BUILD_tests}") message(STATUS " Build tools (xmlwf) ........ ${BUILD_tools}") message(STATUS " Install files .............. ${INSTALL}") From d608f79849ca85f3015b4f63a8f26799b836f360 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Wed, 28 Aug 2019 17:51:31 +0200 Subject: [PATCH 3/8] CMake: Check C rather than C++ compiler for clang for fuzzing --- expat/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/expat/CMakeLists.txt b/expat/CMakeLists.txt index 502b876c..24667e6f 100644 --- a/expat/CMakeLists.txt +++ b/expat/CMakeLists.txt @@ -326,7 +326,7 @@ if(BUILD_tests) endif(BUILD_tests) if(BUILD_fuzzers) - if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + if(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") message(SEND_ERROR "Building fuzz targets without clang is not supported. Please set " "-DCMAKE_C_COMPILER=clang.") From 5031b613529e24e2dae88e5903e5b7f7d7e19c02 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Thu, 29 Aug 2019 00:58:26 +0200 Subject: [PATCH 4/8] CMake: Be more helpful with regard to CMAKE_C_COMPILER_ID --- expat/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/expat/CMakeLists.txt b/expat/CMakeLists.txt index 24667e6f..0a19d50b 100644 --- a/expat/CMakeLists.txt +++ b/expat/CMakeLists.txt @@ -328,8 +328,8 @@ endif(BUILD_tests) if(BUILD_fuzzers) if(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") message(SEND_ERROR - "Building fuzz targets without clang is not supported. Please set " - "-DCMAKE_C_COMPILER=clang.") + "Building fuzz targets without Clang (but ${CMAKE_C_COMPILER_ID}) " + "is not supported. Please set -DCMAKE_C_COMPILER=clang.") endif() string(FIND "${CMAKE_EXE_LINKER_FLAGS}" "-fsanitize" sanitizer_present) From b784c756700be866a65703217526494b108f86b3 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Wed, 28 Aug 2019 18:08:44 +0200 Subject: [PATCH 5/8] CMake: Get off target_link_options of CMake >=3.13 --- expat/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/expat/CMakeLists.txt b/expat/CMakeLists.txt index 0a19d50b..0226a4dc 100644 --- a/expat/CMakeLists.txt +++ b/expat/CMakeLists.txt @@ -352,7 +352,8 @@ if(BUILD_fuzzers) target_compile_definitions(${target_name} PRIVATE ENCODING_FOR_FUZZING=${encoding_type}) target_compile_options(${target_name} PRIVATE -fsanitize=fuzzer-no-link) - target_link_options(${target_name} PRIVATE -fsanitize=fuzzer) + # NOTE: Avoiding target_link_options here only because it needs CMake >=3.13 + set_target_properties(${target_name} PROPERTIES LINK_FLAGS -fsanitize=fuzzer) set_property( TARGET ${target_name} PROPERTY RUNTIME_OUTPUT_DIRECTORY fuzz) endforeach() From f991a45deccc152a8cb4bdf7b9eeb519fdf6b95e Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Wed, 28 Aug 2019 23:24:51 +0200 Subject: [PATCH 6/8] Travis CI: Turn verbosity up for MODE=cmake-oos --- .travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.sh b/.travis.sh index acbe37ac..8d3cd193 100755 --- a/.travis.sh +++ b/.travis.sh @@ -53,7 +53,7 @@ elif [[ ${MODE} = cmake-oos ]]; then mkdir build cd build cmake ${CMAKE_ARGS} .. - make all test + make VERBOSE=1 all test make DESTDIR="${PWD}"/ROOT install find ROOT -printf "%P\n" | sort elif [[ ${MODE} = cppcheck ]]; then From b2274348e24f720196986fd29171858b3ee622a9 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Thu, 29 Aug 2019 01:00:43 +0200 Subject: [PATCH 7/8] CMake: Advertise CXX settings for fuzzer so that C++ tests will link fine --- expat/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/expat/CMakeLists.txt b/expat/CMakeLists.txt index 0226a4dc..98979aed 100644 --- a/expat/CMakeLists.txt +++ b/expat/CMakeLists.txt @@ -329,7 +329,8 @@ if(BUILD_fuzzers) if(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") message(SEND_ERROR "Building fuzz targets without Clang (but ${CMAKE_C_COMPILER_ID}) " - "is not supported. Please set -DCMAKE_C_COMPILER=clang.") + "is not supported. Please set " + "-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++.") endif() string(FIND "${CMAKE_EXE_LINKER_FLAGS}" "-fsanitize" sanitizer_present) @@ -338,6 +339,7 @@ if(BUILD_fuzzers) "There was no sanitizer present when building the fuzz targets. " "This is likely in error - consider adding " "-DCMAKE_C_FLAGS='-fsanitize=' and " + "-DCMAKE_CXX_FLAGS='-fsanitize=' and " "-DCMAKE_EXE_LINKER_FLAGS='-fsanitize=' to your cmake " "execution.") endif() From 42d4f61db04c6dc432a6cd7c783ef8925e80cf30 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Thu, 29 Aug 2019 01:01:31 +0200 Subject: [PATCH 8/8] Travis CI: Make MODE=cmake-oos build fuzzing code as well --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0a1e23a2..3defccee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ matrix: - os: linux env: MODE=clang-format - os: linux - env: MODE=cmake-oos CMAKE_ARGS=-DXML_ATTR_INFO=ON + env: MODE=cmake-oos CMAKE_ARGS="-DXML_ATTR_INFO=ON -DBUILD_fuzzers=ON -DCMAKE_C_FLAGS=-fsanitize=address -DCMAKE_CXX_FLAGS=-fsanitize=address -DCMAKE_EXE_LINKER_FLAGS=-fsanitize=address -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++" - os: linux env: MODE=qa-sh QA_COMPILER=clang CC=clang CXX=clang++ LD=clang++ QA_SANITIZER=address CONFIGURE_ARGS=--enable-xml-attr-info - os: linux