CMakeLists.txt 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #
  2. # Copyright (C) 2015-2020 Felix Weinrank
  3. #
  4. # All rights reserved.
  5. #
  6. # Redistribution and use in source and binary forms, with or without
  7. # modification, are permitted provided that the following conditions
  8. # are met:
  9. # 1. Redistributions of source code must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. # 2. Redistributions in binary form must reproduce the above copyright
  12. # notice, this list of conditions and the following disclaimer in the
  13. # documentation and/or other materials provided with the distribution.
  14. # 3. Neither the name of the project nor the names of its contributors
  15. # may be used to endorse or promote products derived from this software
  16. # without specific prior written permission.
  17. #
  18. # THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
  19. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21. # ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
  22. # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  24. # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  25. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  26. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  27. # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. # SUCH DAMAGE.
  29. #
  30. #project(usrsctp-fuzzer C)
  31. #################################################
  32. # INCLUDE MODULES
  33. #################################################
  34. include(CheckIncludeFile)
  35. #################################################
  36. # CHECK INCLUDES
  37. #################################################
  38. include_directories(${CMAKE_SOURCE_DIR}/usrsctplib)
  39. #################################################
  40. # OS DEPENDENT
  41. #################################################
  42. if (CMAKE_SYSTEM_NAME MATCHES "Linux")
  43. add_definitions(-D_GNU_SOURCE)
  44. endif ()
  45. if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
  46. add_definitions(-D__APPLE_USE_RFC_2292)
  47. endif ()
  48. #################################################
  49. # COMPILER FLAGS
  50. #################################################
  51. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-gnu-zero-variadic-macro-arguments -Wno-unused-variable")
  52. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=fuzzer")
  53. #################################################
  54. # PROGRAMS
  55. #################################################
  56. # FUZZING_STAGE LEVELS
  57. # 0 - MULTI - based on input
  58. # 1 - COOKIE_WAIT
  59. # 2 - COOKIE_ECHO
  60. # 3 - ESTABLISHED
  61. # 4 - DATA SENT
  62. # 5 - DATA RECEIVED
  63. add_executable(fuzzer_listen fuzzer_listen.c ../programs/programs_helper.c)
  64. target_link_libraries(fuzzer_listen usrsctp)
  65. add_executable(fuzzer_listen_verbose fuzzer_listen.c ../programs/programs_helper.c)
  66. target_compile_definitions(fuzzer_listen_verbose PRIVATE FUZZ_VERBOSE)
  67. target_link_libraries(fuzzer_listen_verbose usrsctp)
  68. add_executable(fuzzer_fragment fuzzer_fragment.c ../programs/programs_helper.c)
  69. target_link_libraries(fuzzer_fragment usrsctp)
  70. add_executable(fuzzer_connect_multi fuzzer_connect.c ../programs/programs_helper.c)
  71. target_compile_definitions(fuzzer_connect_multi PRIVATE FUZZING_STAGE=0)
  72. target_link_libraries(fuzzer_connect_multi usrsctp)
  73. add_executable(fuzzer_connect_multi_verbose fuzzer_connect.c ../programs/programs_helper.c)
  74. target_compile_definitions(fuzzer_connect_multi_verbose PRIVATE FUZZING_STAGE=0 FUZZ_VERBOSE)
  75. target_link_libraries(fuzzer_connect_multi_verbose usrsctp)
  76. # add_executable(fuzzer_connect_cookie_wait fuzzer_connect.c)
  77. # target_compile_definitions(fuzzer_connect_cookie_wait PRIVATE FUZZING_STAGE=1)
  78. # target_link_libraries(fuzzer_connect_cookie_wait usrsctp)
  79. # add_executable(fuzzer_connect_cookie_echoed fuzzer_connect.c)
  80. # target_compile_definitions(fuzzer_connect_cookie_echoed PRIVATE FUZZING_STAGE=2)
  81. # target_link_libraries(fuzzer_connect_cookie_echoed usrsctp)
  82. # add_executable(fuzzer_connect_established fuzzer_connect.c)
  83. # target_compile_definitions(fuzzer_connect_established PRIVATE FUZZING_STAGE=3)
  84. # target_link_libraries(fuzzer_connect_established usrsctp)
  85. # add_executable(fuzzer_connect_data_sent fuzzer_connect.c)
  86. # target_compile_definitions(fuzzer_connect_data_sent PRIVATE FUZZING_STAGE=4)
  87. # target_link_libraries(fuzzer_connect_data_sent usrsctp)
  88. # add_executable(fuzzer_connect_data_received fuzzer_connect.c)
  89. # target_compile_definitions(fuzzer_connect_data_received PRIVATE FUZZING_STAGE=5)
  90. # target_link_libraries(fuzzer_connect_data_received usrsctp)