Skip to content

Commit

Permalink
Add check-fuzzers target to Makefile. It reuses existing Janus object…
Browse files Browse the repository at this point in the history
…s to execute regression testing with corpora files.
  • Loading branch information
atoppi committed Apr 1, 2019
1 parent c7b6661 commit 159a856
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
9 changes: 9 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,15 @@ $(dir_present):
$(dir_absent):
echo "not-a-git-repo" | awk 'BEGIN {print "#include \"version.h\""} {print "const char *janus_build_git_sha = \"" $$0"\";"} END {}' > version.c

##
# Fuzzers checking
##

check-fuzzers: FORCE
CC=$(CC) SKIP_JANUS_BUILD=1 LIB_FUZZING_ENGINE=fuzzers/standalone.o ./fuzzers/build.sh
./fuzzers/run.sh rtcp_fuzzer out/rtcp_fuzzer_seed_corpus
./fuzzers/run.sh rtp_fuzzer out/rtp_fuzzer_seed_corpus

.PHONY: FORCE
FORCE:

Expand Down
13 changes: 9 additions & 4 deletions fuzzers/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,15 @@ rm -f $WORK/*.a $WORK/*.o
# Build and archive necessary Janus objects
JANUS_LIB="$WORK/janus-lib.a"
cd $SRC/janus-gateway
./autogen.sh
./configure CC="$FUZZ_CC" CFLAGS="$FUZZ_CFLAGS" $JANUS_CONF_FLAGS
make clean
make -j$(nproc) $JANUS_OBJECTS
# Use this variable to skip Janus objects building
SKIP_JANUS_BUILD=${SKIP_JANUS_BUILD-"0"}
if [ "$SKIP_JANUS_BUILD" -eq "0" ]; then
echo "Building Janus objects"
./autogen.sh
./configure CC="$FUZZ_CC" CFLAGS="$FUZZ_CFLAGS" $JANUS_CONF_FLAGS
make clean
make -j$(nproc) $JANUS_OBJECTS
fi
ar rcs $JANUS_LIB $JANUS_OBJECTS
cd -

Expand Down
5 changes: 5 additions & 0 deletions fuzzers/rtp_fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ int janus_log_level = LOG_NONE;
gboolean janus_log_timestamps = FALSE;
gboolean janus_log_colors = FALSE;

/* This is to avoid linking with openSSL */
int RAND_bytes(uint8_t *key, int len) {
return 0;
}

/* Clone libsrtp srtp_validate_rtp_header */
#define octets_in_rtp_header 12
#define uint32s_in_rtp_header 3
Expand Down
2 changes: 1 addition & 1 deletion fuzzers/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ elif [ -f "$CRASH_FILE" ]; then
elif [ -d "$CRASH_FILE" ]; then
# Run without fuzzing, with an user supplied crashes folder
files=$(find "$CRASH_FILE" -maxdepth 1 -type f)
if [ -z $files ]; then
if [[ -z $files ]]; then
echo "Empty crashes folder specified!"
exit 1
fi
Expand Down

0 comments on commit 159a856

Please sign in to comment.