| 1 |
project(fuzzing CXX) |
| 2 |
|
| 3 |
macro(fuzzer name) |
| 4 |
add_executable(${name} ${name}.c) |
| 5 |
target_link_libraries(${name} PRIVATE ${TORTURE_LINK_LIBRARIES}) |
| 6 |
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") |
| 7 |
set_target_properties(${name} |
| 8 |
PROPERTIES |
| 9 |
COMPILE_FLAGS "-fsanitize=fuzzer" |
| 10 |
LINK_FLAGS "-fsanitize=fuzzer") |
| 11 |
# Run the fuzzer to make sure it works |
| 12 |
add_test(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name} -runs=1) |
| 13 |
# Run the fuzzer with nalloc to make sure it works |
| 14 |
add_test(${name}_nalloc ${CMAKE_CURRENT_BINARY_DIR}/${name} -runs=1) |
| 15 |
set_property(TEST ${name}_nalloc PROPERTY ENVIRONMENT NALLOC_FREQ 32) |
| 16 |
else() |
| 17 |
target_sources(${name} PRIVATE fuzzer.c) |
| 18 |
# Run the fuzzer to make sure it works |
| 19 |
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${name}_corpus") |
| 20 |
file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/${name}_corpus/*") |
| 21 |
set(i 0) |
| 22 |
foreach(file ${files}) |
| 23 |
add_test(${name}_${i} |
| 24 |
${CMAKE_CURRENT_BINARY_DIR}/${name} ${file}) |
| 25 |
math(EXPR i "${i} + 1") |
| 26 |
endforeach() |
| 27 |
endif() |
| 28 |
endif() |
| 29 |
endmacro() |
| 30 |
|
| 31 |
fuzzer(ssh_client_fuzzer) |
| 32 |
fuzzer(ssh_client_config_fuzzer) |
| 33 |
fuzzer(ssh_known_hosts_fuzzer) |
| 34 |
fuzzer(ssh_privkey_fuzzer) |
| 35 |
fuzzer(ssh_pubkey_fuzzer) |
| 36 |
fuzzer(ssh_sshsig_fuzzer) |
| 37 |
if (WITH_SERVER) |
| 38 |
fuzzer(ssh_server_fuzzer) |
| 39 |
fuzzer(ssh_bind_config_fuzzer) |
| 40 |
endif (WITH_SERVER) |