Skip to content

Commit 6efa34b

Browse files
authoredJun 28, 2024
Add a simple fuzzing harness for PDFParser (#266)
* Add a simple libFuzzer / AFL++ fuzzing harness for PDFParser * Add fuzzing corpus
1 parent ec93983 commit 6efa34b

File tree

676 files changed

+1529
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

676 files changed

+1529
-0
lines changed
 

‎CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ option(USE_UNBUNDLED_FALLBACK_BUNDLED "When USE_BUNDLED is false and a certain
1111
option(PDFHUMMUS_NO_DCT "Whether to drop support for DCT streams parsing (will not use LibJpeg)")
1212
option(PDFHUMMUS_NO_TIFF "Whether to drop TIFF Images support (will not use LibTiff)" )
1313
option(PDFHUMMUS_NO_PNG "Whether to drop PNG Images support (will not use LibPng)" )
14+
option(BUILD_FUZZING_HARNESS "Build the fuzzing harness, requires LLVM's clang")
1415

1516
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1617

@@ -161,6 +162,13 @@ if(PROJECT_IS_TOP_LEVEL AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/PDFWriterTesting)
161162
ADD_SUBDIRECTORY(PDFWriterTesting)
162163
endif()
163164

165+
if(BUILD_FUZZING_HARNESS)
166+
add_compile_options(-fsanitize=fuzzer,address -g -O2)
167+
168+
add_executable(PDFParserFuzzingHarness PDFWriterTesting/PDFParserFuzzingHarness.cpp)
169+
target_link_libraries(PDFParserFuzzingHarness PDFWriter -O2 -fsanitize=fuzzer,address -fuse-ld=lld)
170+
endif()
171+
164172
include(InstallRequiredSystemLibraries)
165173
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
166174
set(CPACK_PACKAGE_VERSION_MAJOR "${PDFHummus_VERSION_MAJOR}")

0 commit comments

Comments
 (0)