[vlc-devel] [PATCH] add libfuzzer support

Shaleen Jain shaleen.jain95 at gmail.com
Wed Jun 21 14:36:50 CEST 2017


---
 .gitignore            |  1 +
 configure.ac          |  8 ++++++++
 test/Makefile.am      |  2 ++
 test/fuzz/Makefile.am | 19 +++++++++++++++++++
 4 files changed, 30 insertions(+)
 create mode 100644 test/fuzz/Makefile.am

diff --git a/.gitignore b/.gitignore
index 0b0ee9cc20..fcd0e59213 100644
--- a/.gitignore
+++ b/.gitignore
@@ -45,6 +45,7 @@ wxvlc
 vlc_install_dir/*
 plugins.dat
 patches/*
+*_fuzzer
 
 include/vlc/libvlc_version.h
 
diff --git a/configure.ac b/configure.ac
index 67fc7deb1a..c289b69510 100644
--- a/configure.ac
+++ b/configure.ac
@@ -94,6 +94,13 @@ AS_IF([test -n "${with_binary_version}"],[
          [Binary specific version])
 ])
 
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
+#if !defined(__clang__)
+#error
+#endif])], have_clang=yes, have_clang=no)
+
+AM_CONDITIONAL(HAVE_CLANG, test "x$have_clang" = "xyes")
+
 dnl
 dnl  Check the operating system
 dnl
@@ -4248,6 +4255,7 @@ AC_CONFIG_FILES([
   lib/Makefile
   bin/Makefile
   test/Makefile
+  test/fuzz/Makefile
   modules/hw/mmal/Makefile
   share/vlc.appdata.xml.in
 ])
diff --git a/test/Makefile.am b/test/Makefile.am
index 95d4df6516..30c1bb56b6 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -4,6 +4,8 @@
 
 AUTOMAKE_OPTIONS = subdir-objects
 
+SUBDIRS = fuzz
+
 extra_check_verbose = $(extra_check_verbose_$(V))
 extra_check_verbose_ = $(extra_check_flags__$(AM_DEFAULT_VERBOSITY))
 extra_check_verbose_0 = @echo TEST $@
diff --git a/test/fuzz/Makefile.am b/test/fuzz/Makefile.am
new file mode 100644
index 0000000000..57eb04f13f
--- /dev/null
+++ b/test/fuzz/Makefile.am
@@ -0,0 +1,19 @@
+AUTOMAKE_OPTIONS = subdir-objects
+
+AM_CXXFLAGS = -fsanitize=address -fsanitize-address-use-after-scope -fsanitize=undefined -fno-sanitize-recover=undefined
+if HAVE_CLANG
+AM_CXXFLAGS += -fsanitize-coverage=trace-pc-guard,trace-cmp
+else
+AM_CXXFLAGS += -fsanitize-coverage=trace-pc
+endif
+
+LIBVLCCORE = ../../src/libvlccore.la
+LIBVLC = ../../lib/libvlc.la
+
+LDADD = $(LIBVLCCORE) $(LIBVLC) -L./ -lFuzzer
+
+check_PROGRAMS = \
+	libvlc_demux_fuzzer
+
+libvlc_demux_fuzzer_SOURCES = libvlc_demux_fuzzer.cpp
+
-- 
2.13.1



More information about the vlc-devel mailing list