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

tests_fuzzing_synth_fuzzer_test_SOURCES = tests/fuzzing/synth_fuzzer.c 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_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_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 else
tests_ssml_fuzzer_test_LDADD += tests/libfuzzrunner.la tests_ssml_fuzzer_test_LDADD += tests/libfuzzrunner.la
endif endif

+ 3
- 0
configure.ac View File

TEMP_LIBS="$LIBS" TEMP_LIBS="$LIBS"
HOST_CPU="`$CC -print-target-triple | sed -e 's/-.*//'`" 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_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" CFLAGS="$CFLAGS -fsanitize=fuzzer-no-link"
LIBS="$LIBS $LIBFUZZER_NO_MAIN" LIBS="$LIBS $LIBFUZZER_NO_MAIN"
AC_MSG_CHECKING([if $CC supports fuzzer with the -fsanitize=fuzzer flag]) AC_MSG_CHECKING([if $CC supports fuzzer with the -fsanitize=fuzzer flag])
if test "$have_fuzzer_fuzzer" != yes ; then if test "$have_fuzzer_fuzzer" != yes ; then
CFLAGS="$TEMP_CFLAGS" CFLAGS="$TEMP_CFLAGS"
LIBFUZZER_NO_MAIN="" LIBFUZZER_NO_MAIN=""
LIBFUZZER=""
fi fi
AC_SUBST(LIBFUZZER_NO_MAIN) AC_SUBST(LIBFUZZER_NO_MAIN)
AC_SUBST(LIBFUZZER)
LIBS="$TEMP_LIBS" LIBS="$TEMP_LIBS"
AC_LANG_POP(C) AC_LANG_POP(C)
fi fi

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

} }


/* See http://llvm.org/docs/LibFuzzer.html */ /* 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); extern int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);


int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)


return 0; return 0;
} }

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

Loading…
Cancel
Save