diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-06-27 23:03:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-27 23:03:53 +0200 |
commit | 153116f7fd955bbcfee5fe80996a4619c7a343c3 (patch) | |
tree | 8bbe02cdfdd4720cce9c69f2f552775338f66038 /src | |
parent | 00291fd1811eba348f649f74f4c727625f0be945 (diff) | |
parent | a2f1f76dc38a34d0e3d97f75d1fee527931b6e8a (diff) |
Merge pull request #209 from philipturnbull/libFuzzer
Add libFuzzer harness for oss-fuzz
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 11 | ||||
-rw-r--r-- | src/latex.c | 4 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f52ded6..3197196 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -186,3 +186,14 @@ endif() if(CMAKE_BUILD_TYPE STREQUAL "Ubsan") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined") endif() + +if(CMARK_LIB_FUZZER) + set(FUZZ_HARNESS "cmark-fuzz") + add_executable(${FUZZ_HARNESS} ../test/cmark-fuzz.c ${LIBRARY_SOURCES}) + target_link_libraries(${FUZZ_HARNESS} "${CMAKE_LIB_FUZZER_PATH}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-coverage=trace-pc-guard") + + # cmark is written in C but the libFuzzer runtime is written in C++ which + # needs to link against the C++ runtime. Explicitly link it into cmark-fuzz + set_target_properties(${FUZZ_HARNESS} PROPERTIES LINK_FLAGS "-lstdc++") +endif() diff --git a/src/latex.c b/src/latex.c index 9bd6444..22052d7 100644 --- a/src/latex.c +++ b/src/latex.c @@ -179,6 +179,10 @@ static link_type get_link_type(cmark_node *node) { link_text = node->first_child; cmark_consolidate_text_nodes(link_text); + + if (!link_text) + return NO_LINK; + realurl = (char *)url; realurllen = (int)url_len; if (strncmp(realurl, "mailto:", 7) == 0) { |