Visitar URL original
OSS-Fuzz: Add new fuzzer targets sftp client by arthurscchan · Pull Request #2723 · libssh2/libssh2 · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tests/ossfuzz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,19 @@ else()
endif()
target_link_libraries(ssh2_client_fuzzer ${LIB_STATIC} ${LIBSSH2_LIBS_SOCKET})
set_target_properties(ssh2_client_fuzzer PROPERTIES UNITY_BUILD OFF)

add_executable(ssh2_sftp_client_fuzzer "ssh2_sftp_client_fuzzer.cc" "testinput.h")
target_include_directories(ssh2_sftp_client_fuzzer PRIVATE
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_SOURCE_DIR}/src")
if(LIB_FUZZING_ENGINE)
if(LIB_FUZZING_ENGINE STREQUAL "-fsanitize=fuzzer") # FIXME: compiler-specific
set_property(TARGET ssh2_sftp_client_fuzzer APPEND PROPERTY LINK_OPTIONS "${LIB_FUZZING_ENGINE}")
else()
target_link_libraries(ssh2_sftp_client_fuzzer ${LIB_FUZZING_ENGINE})
endif()
else()
target_link_libraries(ssh2_sftp_client_fuzzer standaloneengine)
endif()
target_link_libraries(ssh2_sftp_client_fuzzer ${LIB_STATIC} ${LIBSSH2_LIBS_SOCKET})
set_target_properties(ssh2_sftp_client_fuzzer PROPERTIES UNITY_BUILD OFF)
9 changes: 8 additions & 1 deletion tests/ossfuzz/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

AM_CPPFLAGS = -I$(top_builddir)/include
AM_CPPFLAGS += -DLIBSSH2_TESTS
# In-tree fuzzers may exercise internal APIs (declared under src/).
AM_CPPFLAGS += -I$(top_srcdir)/src

LDADD = $(top_builddir)/src/libssh2.la

Expand All @@ -23,7 +25,8 @@ noinst_LIBRARIES =

if USE_OSSFUZZERS
noinst_PROGRAMS += \
ssh2_client_fuzzer
ssh2_client_fuzzer \
ssh2_sftp_client_fuzzer

noinst_LIBRARIES += \
libstandaloneengine.a
Expand All @@ -33,6 +36,10 @@ ssh2_client_fuzzer_SOURCES = ssh2_client_fuzzer.cc testinput.h
ssh2_client_fuzzer_CXXFLAGS = $(AM_CXXFLAGS) $(FUZZ_FLAG)
ssh2_client_fuzzer_LDFLAGS = $(AM_LDFLAGS) -static

ssh2_sftp_client_fuzzer_SOURCES = ssh2_sftp_client_fuzzer.cc testinput.h
ssh2_sftp_client_fuzzer_CXXFLAGS = $(AM_CXXFLAGS) $(FUZZ_FLAG)
ssh2_sftp_client_fuzzer_LDFLAGS = $(AM_LDFLAGS) -static

libstandaloneengine_a_SOURCES = standaloneengine.cc
libstandaloneengine_a_CXXFLAGS = $(AM_CXXFLAGS)

Expand Down
8 changes: 7 additions & 1 deletion tests/ossfuzz/ossfuzz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,11 @@ autoreconf -fi
--enable-debug
make V=1

# Copy the fuzzer to the output directory.
# Copy the fuzzers to the output directory.
cp -v tests/ossfuzz/ssh2_client_fuzzer "$OUT/"
cp -v tests/ossfuzz/ssh2_sftp_client_fuzzer "$OUT/"

# Package the sftp client fuzzer's seed corpus and dictionary.
zip -qj "$OUT/ssh2_sftp_client_fuzzer_seed_corpus.zip" \
tests/ossfuzz/ssh2_sftp_client_fuzzer_seed_corpus/*
cp -v tests/ossfuzz/ssh2_sftp_client_fuzzer.dict "$OUT/"
Loading
Loading