1# Copyright (c) 2019 Yubico AB. All rights reserved.
2# Use of this source code is governed by a BSD-style
3# license that can be found in the LICENSE file.
4
5list(APPEND COMPAT_SOURCES
6	../openbsd-compat/strlcpy.c
7	../openbsd-compat/strlcat.c
8)
9
10list(APPEND COMMON_SOURCES
11	libfuzzer.c
12	mutator_aux.c
13)
14
15set(FUZZ_LDFLAGS "-fsanitize=fuzzer")
16
17# fuzz_cred
18add_executable(fuzz_cred fuzz_cred.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
19target_compile_options(fuzz_cred PRIVATE ${FUZZ_LDFLAGS})
20set_target_properties(fuzz_cred PROPERTIES LINK_FLAGS ${FUZZ_LDFLAGS})
21target_link_libraries(fuzz_cred fido2_shared)
22
23# fuzz_assert
24add_executable(fuzz_assert fuzz_assert.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
25target_compile_options(fuzz_assert PRIVATE ${FUZZ_LDFLAGS})
26set_target_properties(fuzz_assert PROPERTIES LINK_FLAGS ${FUZZ_LDFLAGS})
27target_link_libraries(fuzz_assert fido2_shared)
28
29# fuzz_mgmt
30add_executable(fuzz_mgmt fuzz_mgmt.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
31target_compile_options(fuzz_mgmt PRIVATE ${FUZZ_LDFLAGS})
32set_target_properties(fuzz_mgmt PROPERTIES LINK_FLAGS ${FUZZ_LDFLAGS})
33target_link_libraries(fuzz_mgmt fido2_shared)
34
35# fuzz_credman
36add_executable(fuzz_credman fuzz_credman.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
37target_compile_options(fuzz_credman PRIVATE ${FUZZ_LDFLAGS})
38set_target_properties(fuzz_credman PROPERTIES LINK_FLAGS ${FUZZ_LDFLAGS})
39target_link_libraries(fuzz_credman fido2_shared)
40
41# fuzz_bio
42add_executable(fuzz_bio fuzz_bio.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
43target_compile_options(fuzz_bio PRIVATE ${FUZZ_LDFLAGS})
44set_target_properties(fuzz_bio PROPERTIES LINK_FLAGS ${FUZZ_LDFLAGS})
45target_link_libraries(fuzz_bio fido2_shared)
46
47# fuzz_hid
48add_executable(fuzz_hid fuzz_hid.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
49target_compile_options(fuzz_hid PRIVATE ${FUZZ_LDFLAGS})
50set_target_properties(fuzz_hid PROPERTIES LINK_FLAGS ${FUZZ_LDFLAGS})
51target_link_libraries(fuzz_hid fido2_shared)
52
53# fuzz_netlink
54add_executable(fuzz_netlink fuzz_netlink.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
55target_compile_options(fuzz_netlink PRIVATE ${FUZZ_LDFLAGS})
56set_target_properties(fuzz_netlink PROPERTIES LINK_FLAGS ${FUZZ_LDFLAGS})
57target_link_libraries(fuzz_netlink fido2_shared)
58
59# fuzz_largeblob
60add_executable(fuzz_largeblob fuzz_largeblob.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
61target_compile_options(fuzz_largeblob PRIVATE ${FUZZ_LDFLAGS})
62set_target_properties(fuzz_largeblob PROPERTIES LINK_FLAGS ${FUZZ_LDFLAGS})
63target_link_libraries(fuzz_largeblob fido2_shared)
64