Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,25 @@ if (NOT MONGOCRYPT_CRYPTO STREQUAL none)
endif ()
endif ()

option (ENABLE_FUZZING "Build fuzzing targets. Requires a compiler supporting -fsanitize=fuzzer." OFF)
if (ENABLE_FUZZING)
include (CheckCCompilerFlag)
set (CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
check_c_compiler_flag ("-fsanitize=fuzzer-no-link" COMPILER_SUPPORTS_FUZZER)
unset (CMAKE_TRY_COMPILE_TARGET_TYPE)
if (NOT COMPILER_SUPPORTS_FUZZER)
message (FATAL_ERROR
"ENABLE_FUZZING is ON but the compiler does not support -fsanitize=fuzzer. "
)
endif ()

add_executable (fuzz_mongocrypt EXCLUDE_FROM_ALL test/fuzz_mongocrypt.c)
target_include_directories (fuzz_mongocrypt PRIVATE ./src)
target_link_libraries (fuzz_mongocrypt PRIVATE mongocrypt_static _mongocrypt::libbson_for_static)
target_compile_options (fuzz_mongocrypt PRIVATE -fsanitize=fuzzer)
target_link_options (fuzz_mongocrypt PRIVATE -fsanitize=fuzzer)
endif ()

if (ENABLE_STATIC)
set (TARGETS_TO_INSTALL mongocrypt mongocrypt_static)
else ()
Expand Down
Comment thread
mdb-ad marked this conversation as resolved.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added test/data/fuzz_mongocrypt_corpus/op0_with_extra
Binary file not shown.
Binary file added test/data/fuzz_mongocrypt_corpus/op1_decrypt_doc
Binary file not shown.
Binary file not shown.
Binary file added test/data/fuzz_mongocrypt_corpus/op1_with_extra
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added test/data/fuzz_mongocrypt_corpus/op2_with_extra
Binary file not shown.
Binary file not shown.
Binary file added test/data/fuzz_mongocrypt_corpus/op3_with_extra
Binary file not shown.
Binary file added test/data/fuzz_mongocrypt_corpus/op4_datakey
Binary file not shown.
Binary file added test/data/fuzz_mongocrypt_corpus/op4_with_extra
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added test/data/fuzz_mongocrypt_corpus/op5_with_extra
Binary file not shown.
Binary file not shown.
Binary file added test/data/fuzz_mongocrypt_corpus/op6_with_extra
Binary file not shown.
Loading