Browse Source

fuzz: Use main from libfuzzer (#2069)

master
Samuel Thibault 5 months ago
parent
commit
de5caa9503
No account linked to committer's email address
3 changed files with 5 additions and 7 deletions
  1. 2
    1
      Makefile.am
  2. 3
    0
      configure.ac
  3. 0
    6
      tests/fuzzing/synth_fuzzer.c

+ 2
- 1
Makefile.am View File

@@ -358,7 +358,8 @@ noinst_PROGRAMS = tests/fuzzing/synth_fuzzer.test
tests_fuzzing_synth_fuzzer_test_SOURCES = tests/fuzzing/synth_fuzzer.c
tests_fuzzing_synth_fuzzer_test_LDADD = src/libespeak-ng.la
tests_fuzzing_synth_fuzzer_test_CFLAGS= ${AM_CFLAGS} -DPATH_ESPEAK_DATA=\"$(abs_top_srcdir)/espeak-ng-data\" -Isrc/libespeak-ng
tests_fuzzing_synth_fuzzer_test_LDFLAGS= ${AM_LDFLAGS} -static -lm -Wl,-z,relro ${PCAUDIOLIB_LIBS} ${LIBFUZZER_NO_MAIN}
tests_fuzzing_synth_fuzzer_test_LDFLAGS= ${AM_LDFLAGS} -static -lm -Wl,-z,relro ${PCAUDIOLIB_LIBS} ${LIBFUZZER}
tests_ssml_fuzzer_test_LDFLAGS = ${AM_LDFLAGS} ${LIBFUZZER}
else
tests_ssml_fuzzer_test_LDADD += tests/libfuzzrunner.la
endif

+ 3
- 0
configure.ac View File

@@ -142,6 +142,7 @@ if test "$with_libfuzzer" = yes ; then
TEMP_LIBS="$LIBS"
HOST_CPU="`$CC -print-target-triple | sed -e 's/-.*//'`"
LIBFUZZER_NO_MAIN="`$CC -print-file-name=libclang_rt.fuzzer_no_main-$HOST_CPU.a` -lstdc++ -lm"
LIBFUZZER="`$CC -print-file-name=libclang_rt.fuzzer-$HOST_CPU.a` -lstdc++ -lm"
CFLAGS="$CFLAGS -fsanitize=fuzzer-no-link"
LIBS="$LIBS $LIBFUZZER_NO_MAIN"
AC_MSG_CHECKING([if $CC supports fuzzer with the -fsanitize=fuzzer flag])
@@ -153,8 +154,10 @@ if test "$with_libfuzzer" = yes ; then
if test "$have_fuzzer_fuzzer" != yes ; then
CFLAGS="$TEMP_CFLAGS"
LIBFUZZER_NO_MAIN=""
LIBFUZZER=""
fi
AC_SUBST(LIBFUZZER_NO_MAIN)
AC_SUBST(LIBFUZZER)
LIBS="$TEMP_LIBS"
AC_LANG_POP(C)
fi

+ 0
- 6
tests/fuzzing/synth_fuzzer.c View File

@@ -40,8 +40,6 @@ espeak_callback(short *data, int samples, espeak_EVENT *events)
}

/* See http://llvm.org/docs/LibFuzzer.html */
extern int LLVMFuzzerRunDriver(int *argc, char ***argv,
int (*UserCb)(const uint8_t *Data, size_t Size));
extern int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
@@ -79,7 +77,3 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)

return 0;
}

int main(int argc, char *argv[]) {
LLVMFuzzerRunDriver(&argc, &argv, LLVMFuzzerTestOneInput);
}

Loading…
Cancel
Save