# HG changeset patch # Node ID 351900a245b8 # Parent 13a246aa0656 diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -2532,6 +2532,18 @@ AM_CONDITIONAL(HAVE_DOXYGEN, test "x$enable_doxygen" = "xyes") AM_CONDITIONAL(HAVE_XSLTPROC, test "x$enable_devhelp" = "xyes") + +AC_ARG_ENABLE([fuzzing], [--enable-fuzzing Turn on fuzzing], + [case "${enableval}" in yes) fuzzing=true ;; no) fuzzing=false ;; *) AC_MSG_ERROR([bad value ${enableval} for --enable-fuzzing]) ;; esac],[fuzzing=false]) +AM_CONDITIONAL([FUZZ], [test x$fuzzing = xtrue]) + +if test "x$enable_fuzzing" = "xyes" ; then + if ! test "x$CC" = "xclang" ; then + AC_MSG_ERROR(["You need to set CC=clang to use --enable-fuzzing, used $CC"]) + fi +fi + + AC_ARG_ENABLE(debug, [AC_HELP_STRING([--enable-debug], [compile with debugging support])], , enable_debug=no) diff --git a/libpurple/tests/Makefile.am b/libpurple/tests/Makefile.am --- a/libpurple/tests/Makefile.am +++ b/libpurple/tests/Makefile.am @@ -4,8 +4,21 @@ clean-local: -rm -rf libpurple.. + check_PROGRAMS=check_libpurple +if FUZZ +fuzz_programs=\ + fuzz_html_to_xhtml \ + fuzz_jabber_caps \ + fuzz_jabber_id_new \ + fuzz_markup_strip_html \ + fuzz_mime \ + fuzz_xmlnode +check_PROGRAMS+=$(fuzz_programs) +endif + + check_libpurple_SOURCES=\ check_libpurple.c \ tests.h \ @@ -33,4 +46,31 @@ @CHECK_LIBS@ \ $(GLIB_LIBS) + +if FUZZ +fuzz_xmlnode_SOURCES=fuzz_xmlnode.c +fuzz_xmlnode_LDADD=$(check_libpurple_LDADD) +fuzz_xmlnode_CFLAGS=-fsanitize=fuzzer,address $(check_libpurple_CFLAGS) + +fuzz_jabber_id_new_SOURCES=fuzz_jabber_id_new.c +fuzz_jabber_id_new_LDADD=$(check_libpurple_LDADD) +fuzz_jabber_id_new_CFLAGS=-fsanitize=fuzzer,address $(check_libpurple_CFLAGS) + +fuzz_jabber_caps_SOURCES=fuzz_jabber_caps.c +fuzz_jabber_caps_LDADD=$(check_libpurple_LDADD) +fuzz_jabber_caps_CFLAGS=-fsanitize=fuzzer,address $(check_libpurple_CFLAGS) + +fuzz_mime_SOURCES=fuzz_mime.c +fuzz_mime_LDADD=$(check_libpurple_LDADD) +fuzz_mime_CFLAGS=-fsanitize=fuzzer,address $(check_libpurple_CFLAGS) + +fuzz_html_to_xhtml_SOURCES=fuzz_html_to_xhtml.c +fuzz_html_to_xhtml_LDADD=$(check_libpurple_LDADD) +fuzz_html_to_xhtml_CFLAGS=-fsanitize=fuzzer,address $(check_libpurple_CFLAGS) + +fuzz_markup_strip_html_SOURCES=fuzz_markup_strip_html.c +fuzz_markup_strip_html_LDADD=$(check_libpurple_LDADD) +fuzz_markup_strip_html_CFLAGS=-fsanitize=fuzzer,address $(check_libpurple_CFLAGS) endif + +endif diff --git a/libpurple/tests/dictionaries/html.dict b/libpurple/tests/dictionaries/html.dict new file mode 100644 --- /dev/null +++ b/libpurple/tests/dictionaries/html.dict @@ -0,0 +1,478 @@ +# +# AFL dictionary for HTML parsers +# ------------------------------- +# +# A basic collection of HTML string likely to matter to HTML parsers. +# +# Created by Michal Zalewski +# + +tag_a="" +tag_abbr="" +tag_acronym="" +tag_address="
" +tag_annotation_xml="" +tag_applet="" +tag_area="" +tag_article="
" +tag_aside="