Debian Codegraph @

debian/patches/fuzz-link

raw
1 commit 4d3160a8a6fb571bfaaf540f57a32c99b44b6fa7
2 Author: Samuel Thibault <[email protected]>
3 Date: Sun Dec 15 00:40:56 2024 +0100
4
5 fuzz: Use main from libfuzzer
6
7 diff --git a/Makefile.am b/Makefile.am
8 index 3b002e4d..6d7e5764 100644
9 --- a/Makefile.am
10 +++ b/Makefile.am
11 @@ -358,7 +358,8 @@ noinst_PROGRAMS = tests/fuzzing/synth_fuzzer.test
12 tests_fuzzing_synth_fuzzer_test_SOURCES = tests/fuzzing/synth_fuzzer.c
13 tests_fuzzing_synth_fuzzer_test_LDADD = src/libespeak-ng.la
14 tests_fuzzing_synth_fuzzer_test_CFLAGS= ${AM_CFLAGS} -DPATH_ESPEAK_DATA=\"$(abs_top_srcdir)/espeak-ng-data\" -Isrc/libespeak-ng
15 -tests_fuzzing_synth_fuzzer_test_LDFLAGS= ${AM_LDFLAGS} -static -lm -Wl,-z,relro ${PCAUDIOLIB_LIBS} ${LIBFUZZER_NO_MAIN}
16 +tests_fuzzing_synth_fuzzer_test_LDFLAGS= ${AM_LDFLAGS} -static -lm -Wl,-z,relro ${PCAUDIOLIB_LIBS} ${LIBFUZZER}
17 +tests_ssml_fuzzer_test_LDFLAGS = ${AM_LDFLAGS} ${LIBFUZZER}
18 else
19 tests_ssml_fuzzer_test_LDADD += tests/libfuzzrunner.la
20 endif
21 diff --git a/configure.ac b/configure.ac
22 index b3861a64..f0e8996d 100644
23 --- a/configure.ac
24 +++ b/configure.ac
25 @@ -142,6 +142,7 @@ if test "$with_libfuzzer" = yes ; then
26 TEMP_LIBS="$LIBS"
27 HOST_CPU="`$CC -print-target-triple | sed -e 's/-.*//'`"
28 LIBFUZZER_NO_MAIN="`$CC -print-file-name=libclang_rt.fuzzer_no_main-$HOST_CPU.a` -lstdc++ -lm"
29 + LIBFUZZER="`$CC -print-file-name=libclang_rt.fuzzer-$HOST_CPU.a` -lstdc++ -lm"
30 CFLAGS="$CFLAGS -fsanitize=fuzzer-no-link"
31 LIBS="$LIBS $LIBFUZZER_NO_MAIN"
32 AC_MSG_CHECKING([if $CC supports fuzzer with the -fsanitize=fuzzer flag])
33 @@ -153,8 +154,10 @@ if test "$with_libfuzzer" = yes ; then
34 if test "$have_fuzzer_fuzzer" != yes ; then
35 CFLAGS="$TEMP_CFLAGS"
36 LIBFUZZER_NO_MAIN=""
37 + LIBFUZZER=""
38 fi
39 AC_SUBST(LIBFUZZER_NO_MAIN)
40 + AC_SUBST(LIBFUZZER)
41 LIBS="$TEMP_LIBS"
42 AC_LANG_POP(C)
43 fi
44 diff --git a/tests/fuzzing/synth_fuzzer.c b/tests/fuzzing/synth_fuzzer.c
45 index 3cf0007d..953d1384 100644
46 --- a/tests/fuzzing/synth_fuzzer.c
47 +++ b/tests/fuzzing/synth_fuzzer.c
48 @@ -39,10 +39,6 @@ espeak_callback(short *data, int samples, espeak_EVENT *events)
49 return 0;
50 }
51
52 -/* See http://llvm.org/docs/LibFuzzer.html */
53 -extern int LLVMFuzzerRunDriver(int *argc, char ***argv,
54 - int (*UserCb)(const uint8_t *Data, size_t Size));
55 -
56 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
57 {
58 int buflength = size+1;
59 @@ -78,7 +74,3 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
60
61 return 0;
62 }
63 -
64 -int main(int argc, char *argv[]) {
65 - LLVMFuzzerRunDriver(&argc, &argv, LLVMFuzzerTestOneInput);
66 -}