Skip to content

Commit e9816ff

Browse files
authored
libssh: Fix build with mock server (#15171)
This PR fixes the build for project libssh to prepare for fuzzer build with the mock server. Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
1 parent db064ec commit e9816ff

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

projects/libssh/build.sh

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,24 @@ for f in $fuzzers; do
4848
$CC $CFLAGS -I$SRC/libssh/include/ -I$SRC/libssh/src/ -I$BUILD/ -I$BUILD/include/ \
4949
-c "$f" -O0 -g
5050

51-
# Fuzzers that use the mock server need the mock object and pthread
52-
EXTRA_OBJS=""
53-
EXTRA_LIBS=""
54-
if [ -f ssh_server_mock.o ]; then
55-
case "$fuzzerName" in
56-
ssh_scp_fuzzer|ssh_sftp_fuzzer)
57-
EXTRA_OBJS="ssh_server_mock.o"
58-
EXTRA_LIBS="-lpthread"
59-
;;
60-
esac
51+
# Check if this fuzzer needs ssh_server_mock
52+
if [ "$fuzzerName" = "ssh_scp_fuzzer" ] || [ "$fuzzerName" = "ssh_sftp_fuzzer" ]; then
53+
echo "Linking $fuzzerName with ssh_server_mock"
54+
$CXX $CXXFLAGS $fuzzerName.o ssh_server_mock.o \
55+
-o "$OUT/$fuzzerName" -O0 -g \
56+
$LIB_FUZZING_ENGINE ./src/libssh.a -Wl,-Bstatic -lcrypto -lz -Wl,-Bdynamic -lpthread
57+
else
58+
$CXX $CXXFLAGS $fuzzerName.o \
59+
-o "$OUT/$fuzzerName" -O0 -g \
60+
$LIB_FUZZING_ENGINE ./src/libssh.a -Wl,-Bstatic -lcrypto -lz -Wl,-Bdynamic
6161
fi
6262

63-
$CXX $CXXFLAGS $fuzzerName.o $EXTRA_OBJS \
64-
-o "$OUT/$fuzzerName" -O0 -g \
65-
$LIB_FUZZING_ENGINE ./src/libssh.a -Wl,-Bstatic -lcrypto -lz -Wl,-Bdynamic $EXTRA_LIBS
66-
6763
if [ -d "$SRC/libssh/tests/fuzz/${fuzzerName}_corpus" ]; then
6864
zip -j $OUT/${fuzzerName}_seed_corpus.zip $SRC/libssh/tests/fuzz/${fuzzerName}_corpus/*
6965
cp $OUT/${fuzzerName}_seed_corpus.zip $OUT/${fuzzerName}_nalloc_seed_corpus.zip
7066
fi
7167

7268
cp $OUT/${fuzzerName} $OUT/${fuzzerName}_nalloc
7369
done
70+
7471
popd

0 commit comments

Comments
 (0)