fixed OSS-Fuzz builds and added CMake targets (#2577)

* fixed compilation of OSS-Fuzz clients

* added preliminary CMake target for fuzz-client - also added *_sanitized targets of dependencies (only available with Clang)

* added oss-fuzz build to Travis CI
This commit is contained in:
Oliver Stöneberg 2020-03-31 09:33:58 +02:00 committed by GitHub
parent c78e3e7c03
commit 28cd5d7ea2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 42 additions and 4 deletions

View File

@ -164,6 +164,8 @@ matrix:
- ./testrunner TestSymbolDatabase
# check .json files
- find . -name '*.json' -not -path '*/\.*' | xargs jsonlint -s
# build OSS-Fuzz clients
- make -j2 CXXFLAGS="-fsanitize=address" -C oss-fuzz
# check if dmake needs to be rerun (this job may fail)
- name: "rerun dmake?"

View File

@ -28,5 +28,6 @@ add_subdirectory(cli) # Client application
add_subdirectory(test) # Tests
ADD_SUBDIRECTORY(gui) # Graphical application
ADD_SUBDIRECTORY(tools/triage) # Triage tool
add_subdirectory(oss-fuzz) # OSS-Fuzz clients
include(cmake/printInfo.cmake REQUIRED)

View File

@ -2,5 +2,9 @@ file(GLOB hdrs "*.h")
file(GLOB srcs "*.cpp")
add_library(simplecpp_objs OBJECT ${srcs} ${hdrs})
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_library(simplecpp_objs_sanitized OBJECT ${srcs} ${hdrs})
target_compile_options(simplecpp_objs_sanitized PRIVATE -fsanitize=address)
endif()

View File

@ -2,5 +2,9 @@ file(GLOB hdrs "*.h")
file(GLOB srcs "*.cpp")
add_library(tinyxml_objs OBJECT ${srcs} ${hdrs})
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_library(tinyxml_objs_sanitized OBJECT ${srcs} ${hdrs})
target_compile_options(tinyxml_objs_sanitized PRIVATE -fsanitize=address)
endif()

View File

@ -37,4 +37,7 @@ else()
endif()
add_library(lib_objs OBJECT ${srcs_lib} ${hdrs})
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_library(lib_objs_sanitized OBJECT ${srcs_lib} ${hdrs})
target_compile_options(lib_objs_sanitized PRIVATE -fsanitize=address)
endif()

13
oss-fuzz/CMakeLists.txt Normal file
View File

@ -0,0 +1,13 @@
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_executable(fuzz-client
main.cpp
type2.cpp)
target_include_directories(fuzz-client PRIVATE ${CMAKE_SOURCE_DIR}/lib ${CMAKE_SOURCE_DIR}/externals/simplecpp ${CMAKE_SOURCE_DIR}/externals/tinyxml ${CMAKE_SOURCE_DIR}/externals)
target_compile_options(fuzz-client PRIVATE -fsanitize=fuzzer)
target_link_libraries(fuzz-client PRIVATE simplecpp_objs_sanitized tinyxml_objs_sanitized lib_objs_sanitized)
target_link_options(fuzz-client PRIVATE -fsanitize=address -fsanitize=fuzzer)
add_executable(translate
translate.cpp
type2.cpp)
endif()

View File

@ -19,11 +19,22 @@ public:
cppcheck.check("test.cpp", code);
}
void reportOut(const std::string &outmsg) { }
void reportErr(const ErrorLogger::ErrorMessage &msg) {}
void reportOut(const std::string &outmsg) OVERRIDE {
(void)outmsg;
}
void reportErr(const ErrorLogger::ErrorMessage &msg) OVERRIDE {
(void)msg;
}
void reportProgress(const std::string& filename,
const char stage[],
const unsigned int value) {}
const std::size_t value) OVERRIDE {
(void)filename;
(void)stage;
(void)value;
}
void bughuntingReport(const std::string &str) OVERRIDE {
(void)str;
}
};