From ff16ef3379e06afe44b5e78b8893aeae0cee2b5b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 18 Nov 2015 16:27:32 -0800 Subject: [PATCH] Enable building a bounded version of the library for fuzzing test/fuzzing/hb-fuzzer links against libharfbuzz-fuzzing.so now. --- src/Makefile.am | 16 ++++++++++++++++ test/fuzzing/Makefile.am | 9 ++------- test/fuzzing/README | 6 ++---- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 569978252..7bcdb5e05 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,6 +15,7 @@ DISTCHECK_CONFIGURE_FLAGS = --enable-introspection # Convenience targets: lib: $(BUILT_SOURCES) libharfbuzz.la +fuzzing: $(BUILT_SOURCES) libharfbuzz-fuzzing.la lib_LTLIBRARIES = libharfbuzz.la @@ -219,6 +220,21 @@ pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = harfbuzz.pc EXTRA_DIST += harfbuzz.pc.in +FUZZING_CPPFLAGS= \ + -DHB_MAX_NESTING_LEVEL=3 \ + -DHB_SANITIZE_MAX_EDITS=3 \ + -DHB_BUFFER_MAX_EXPANSION_FACTOR=3 \ + -DHB_BUFFER_MAX_LEN_MIN=8 \ + -DHB_BUFFER_MAX_LEN_DEFAULT=128 \ + $(NULL) +EXTRA_LTLIBRARIES = libharfbuzz-fuzzing.la +libharfbuzz_fuzzing_la_LINK = $(libharfbuzz_la_LINK) +libharfbuzz_fuzzing_la_SOURCES = $(libharfbuzz_la_SOURCES) +libharfbuzz_fuzzing_la_CPPFLAGS = $(libharfbuzz_la_CPPFLAGS) $(FUZZING_CPPFLAGS) +libharfbuzz_fuzzing_la_LDFLAGS = $(libharfbuzz_la_LDFLAGS) +libharfbuzz_fuzzing_la_LIBADD = $(libharfbuzz_la_LIBADD) +EXTRA_libharfbuzz_fuzzing_la_DEPENDENCIES = $(EXTRA_libharfbuzz_la_DEPENDENCIES) + if HAVE_ICU lib_LTLIBRARIES += libharfbuzz-icu.la libharfbuzz_icu_la_SOURCES = hb-icu.cc diff --git a/test/fuzzing/Makefile.am b/test/fuzzing/Makefile.am index e5ea3a887..ebdd09896 100644 --- a/test/fuzzing/Makefile.am +++ b/test/fuzzing/Makefile.am @@ -8,7 +8,7 @@ MAINTAINERCLEANFILES = # Convenience targets: lib: - @$(MAKE) $(AM_MAKEFLAGS) -C $(top_builddir)/src lib + @$(MAKE) $(AM_MAKEFLAGS) -C $(top_builddir)/src fuzzing EXTRA_DIST += \ README \ @@ -25,7 +25,7 @@ AM_CPPFLAGS = \ -I$(top_builddir)/src/ \ $(NULL) LDADD = \ - $(top_builddir)/src/libharfbuzz.la \ + $(top_builddir)/src/libharfbuzz-fuzzing.la \ $(NULL) hb_fuzzer_SOURCES = \ @@ -37,11 +37,6 @@ hb_fuzzer_LDADD = \ hb_fuzzer_CPPFLAGS = \ $(AM_CPPFLAGS) \ -DMAIN \ - -DHB_MAX_NESTING_LEVEL=3 \ - -DHB_SANITIZE_MAX_EDITS=3 \ - -DHB_BUFFER_MAX_EXPANSION_FACTOR=3 \ - -DHB_BUFFER_MAX_LEN_MIN=8 \ - -DHB_BUFFER_MAX_LEN_DEFAULT=128 \ $(NULL) -include $(top_srcdir)/git.mk diff --git a/test/fuzzing/README b/test/fuzzing/README index 47347db27..c858f5d50 100644 --- a/test/fuzzing/README +++ b/test/fuzzing/README @@ -3,10 +3,8 @@ harfbuzz/test/fuzzing/hb-fuzzer.cc with: - Using the most recent Clang - With -fsanitize=address (or =undefined, or a combination) - With -fsanitize-coverage=edge[,8bit-counters,trace-cmp] - - With various defines that limit worst case exponential behavior: - * -DHB_MAX_NESTING_LEVEL=3 - * -DHB_SANITIZE_MAX_EDITS=3 - * See Makefile.am for full list of flags + - With various defines that limit worst case exponential behavior. + See FUZZING_CPPFLAGS in harfbuzz/src/Makefile.am for the list. - link against libFuzzer To run the fuzzer one needs to first obtain a test corpus as a directory