configure.ac | 17 +++++++++++++++-- src/Makefile.am | 4 ++++ src/fuzz/.gitignore | 8 ++++++++ src/fuzz/Makefile.am | 24 ++++++++++++++++++++++++ src/fuzz/cdrfuzzer.cpp | 27 +++++++++++++++++++++++++++ src/fuzz/cmxfuzzer.cpp | 27 +++++++++++++++++++++++++++ 6 files changed, 105 insertions(+), 2 deletions(-)
New commits: commit bc0877e937c29253758b7abd609d4b030efdaba0 Author: David Tardon <dtar...@redhat.com> Date: Thu Mar 30 19:48:09 2017 +0200 add cmx fuzzer Change-Id: I0c7d84c9b3941ba892981fd69e503eb5ea8734cf diff --git a/src/fuzz/Makefile.am b/src/fuzz/Makefile.am index c89522f..8b5e666 100644 --- a/src/fuzz/Makefile.am +++ b/src/fuzz/Makefile.am @@ -1,4 +1,4 @@ -noinst_PROGRAMS = cdrfuzzer +noinst_PROGRAMS = cdrfuzzer cmxfuzzer AM_CXXFLAGS = -I$(top_srcdir)/inc \ $(REVENGE_GENERATORS_CFLAGS) \ @@ -6,12 +6,19 @@ AM_CXXFLAGS = -I$(top_srcdir)/inc \ $(REVENGE_STREAM_CFLAGS) \ $(DEBUG_CXXFLAGS) -cdrfuzzer_LDADD = \ +fuzzer_ldadd = \ $(top_builddir)/src/lib/libcdr-@CDR_MAJOR_VERSION@.@CDR_MINOR_VERSION@.la \ $(REVENGE_GENERATORS_LIBS) \ $(REVENGE_LIBS) \ $(REVENGE_STREAM_LIBS) \ -lFuzzingEngine +cdrfuzzer_LDADD = $(fuzzer_ldadd) + cdrfuzzer_SOURCES = \ cdrfuzzer.cpp + +cmxfuzzer_LDADD = $(fuzzer_ldadd) + +cmxfuzzer_SOURCES = \ + cmxfuzzer.cpp diff --git a/src/fuzz/cmxfuzzer.cpp b/src/fuzz/cmxfuzzer.cpp new file mode 100644 index 0000000..caf9693 --- /dev/null +++ b/src/fuzz/cmxfuzzer.cpp @@ -0,0 +1,27 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * This file is part of the libmspub project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <cstdint> +#include <cstdlib> + +#include <libcdr/libcdr.h> + +#include <librevenge-generators/librevenge-generators.h> + +#include <librevenge-stream/librevenge-stream.h> + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + librevenge::RVNGStringStream input(data, size); + librevenge::RVNGRawDrawingGenerator generator(true); + libcdr::CMXDocument::parse(&input, &generator); + return 0; +} + +/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ commit 38d14756cfc03b3e827963f854b0233f38872aaf Author: David Tardon <dtar...@redhat.com> Date: Thu Mar 30 19:40:01 2017 +0200 create a fuzzing driver for oss-fuzz Change-Id: I0c89a14828fb25b7a6b0d16bf4055b8dd49e1013 diff --git a/configure.ac b/configure.ac index eb45681..c98f391 100644 --- a/configure.ac +++ b/configure.ac @@ -53,7 +53,19 @@ AC_ARG_ENABLE([tools], [enable_tools="$enableval"], [enable_tools=yes] ) -AS_IF([test "x$enable_tools" = "xyes"], [ +AM_CONDITIONAL(BUILD_TOOLS, [test "x$enable_tools" = "xyes"]) + +# ======= +# Fuzzers +# ======= +AC_ARG_ENABLE([fuzzers], + [AS_HELP_STRING([--enable-fuzzers], [Build fuzzer(s)])], + [enable_fuzzers="$enableval"], + [enable_fuzzers=no] +) +AM_CONDITIONAL(BUILD_FUZZERS, [test "x$enable_fuzzers" = "xyes"]) + +AS_IF([test "x$enable_tools" = "xyes" -o "x$enable_fuzzers" = "xyes"], [ PKG_CHECK_MODULES([REVENGE_STREAM],[ librevenge-stream-0.0 ]) @@ -65,7 +77,6 @@ AC_SUBST([REVENGE_STREAM_CFLAGS]) AC_SUBST([REVENGE_STREAM_LIBS]) AC_SUBST([REVENGE_GENERATORS_CFLAGS]) AC_SUBST([REVENGE_GENERATORS_LIBS]) -AM_CONDITIONAL(BUILD_TOOLS, [test "x$enable_tools" = "xyes"]) # ========== # Find lcms2 @@ -345,6 +356,7 @@ src/conv/svg/cmx2xhtml.rc src/conv/text/Makefile src/conv/text/cdr2text.rc src/conv/text/cmx2text.rc +src/fuzz/Makefile src/lib/Makefile src/lib/libcdr.rc src/test/Makefile @@ -366,6 +378,7 @@ AC_MSG_NOTICE([ Build configuration: debug: ${enable_debug} docs: ${build_docs} + fuzzers: ${enable_fuzzers} tests: ${enable_tests} tools: ${enable_tools} werror: ${enable_werror} diff --git a/src/Makefile.am b/src/Makefile.am index 513f18b..1bfc366 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,6 +4,10 @@ if BUILD_TOOLS SUBDIRS += conv endif +if BUILD_FUZZERS +SUBDIRS += fuzz +endif + if BUILD_TESTS SUBDIRS += test endif diff --git a/src/fuzz/.gitignore b/src/fuzz/.gitignore new file mode 100644 index 0000000..df86dfd --- /dev/null +++ b/src/fuzz/.gitignore @@ -0,0 +1,8 @@ +.deps +.libs +*.lo +*.la +*.o +Makefile +Makefile.in +*fuzzer diff --git a/src/fuzz/Makefile.am b/src/fuzz/Makefile.am new file mode 100644 index 0000000..c89522f --- /dev/null +++ b/src/fuzz/Makefile.am @@ -0,0 +1,17 @@ +noinst_PROGRAMS = cdrfuzzer + +AM_CXXFLAGS = -I$(top_srcdir)/inc \ + $(REVENGE_GENERATORS_CFLAGS) \ + $(REVENGE_CFLAGS) \ + $(REVENGE_STREAM_CFLAGS) \ + $(DEBUG_CXXFLAGS) + +cdrfuzzer_LDADD = \ + $(top_builddir)/src/lib/libcdr-@CDR_MAJOR_VERSION@.@CDR_MINOR_VERSION@.la \ + $(REVENGE_GENERATORS_LIBS) \ + $(REVENGE_LIBS) \ + $(REVENGE_STREAM_LIBS) \ + -lFuzzingEngine + +cdrfuzzer_SOURCES = \ + cdrfuzzer.cpp diff --git a/src/fuzz/cdrfuzzer.cpp b/src/fuzz/cdrfuzzer.cpp new file mode 100644 index 0000000..3450751 --- /dev/null +++ b/src/fuzz/cdrfuzzer.cpp @@ -0,0 +1,27 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * This file is part of the libmspub project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <cstdint> +#include <cstdlib> + +#include <libcdr/libcdr.h> + +#include <librevenge-generators/librevenge-generators.h> + +#include <librevenge-stream/librevenge-stream.h> + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + librevenge::RVNGStringStream input(data, size); + librevenge::RVNGRawDrawingGenerator generator(true); + libcdr::CDRDocument::parse(&input, &generator); + return 0; +} + +/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits