Skip to content

Commit 4a1f2a4

Browse files
committed
Update fuzz target
1 parent 7031c46 commit 4a1f2a4

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

fuzz/CMakeLists.txt

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
1-
add_executable(fuzz_pcap onefile.c fuzz_pcap.c)
2-
target_link_libraries(fuzz_pcap netdissect ${TCPDUMP_LINK_LIBRARIES})
1+
set(fuzz_pcap_src fuzz_pcap.c)
2+
set(fuzz_pcap_libs netdissect ${TCPDUMP_LINK_LIBRARIES})
3+
4+
IF(DEFINED ENV{LIB_FUZZING_ENGINE})
5+
set(fuzz_pcap_libs ${fuzz_pcap_libs} $ENV{LIB_FUZZING_ENGINE})
6+
else()
7+
set(fuzz_pcap_src ${fuzz_pcap_src} onefile.c)
8+
endif()
9+
10+
add_executable(fuzz_pcap ${fuzz_pcap_src})
11+
set_target_properties(fuzz_pcap PROPERTIES LINKER_LANGUAGE CXX)
12+
target_link_libraries(fuzz_pcap ${fuzz_pcap_libs})

fuzz/fuzz_pcap.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
9494
fprintf(outfile, "Couldn't open pcap file %s\n", errbuf);
9595
return 0;
9696
}
97-
if (lookup_printer(pcap_datalink(pkts)) == NULL) {
97+
if_printer_t printer;
98+
printer = lookup_printer(&Ndo, pcap_datalink(pkts));
99+
if (printer.printer == NULL) {
98100
//do not go further if we have no printer
99101
pcap_close(pkts);
100102
return 0;

0 commit comments

Comments
 (0)