[vlc-devel] [PATCH] add libfuzzer support

Hugo Beauzée-Luyssen hugo at beauzee.fr
Wed Jun 21 14:46:49 CEST 2017


Hi,

On Wed, Jun 21, 2017, at 02:36 PM, Shaleen Jain wrote:
> ---
>  .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")
> +

As pointed out by Marvin, it would be more idiomatic to use
ax_check_compile_flag (or something similar) to enable flags
conditionally.

>  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

You need to check for libfuzzer presence in the configure. Also, I'm not
sure running fuzz testing for each 'make check' is a good idea.
I'm not sure what would be the best way to do this, but I'd be in favor
of a separate target. Fuzz testing will most likely be quite long at
some point, and we don't want to make all our source builds that run
make check/make distcheck last for many hours.

> +
> +check_PROGRAMS = \
> +       libvlc_demux_fuzzer
> +
> +libvlc_demux_fuzzer_SOURCES = libvlc_demux_fuzzer.cpp

I think you forgot to add the file :)

> +
> -- 
> 2.13.1
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


-- 
  Hugo Beauzée-Luyssen
  hugo at beauzee.fr


More information about the vlc-devel mailing list