configure.ac | 19 ++++++++++++++++--- src/Makefile.am | 4 ++++ src/conv/raw/Makefile.am | 7 +------ src/conv/svg/Makefile.am | 7 +------ src/fuzz/.gitignore | 8 ++++++++ src/fuzz/Makefile.am | 17 +++++++++++++++++ src/fuzz/pubfuzz.cpp | 27 +++++++++++++++++++++++++++ src/lib/MSPUBParser97.cpp | 7 ++++--- 8 files changed, 78 insertions(+), 18 deletions(-)
New commits: commit 5655d4ec140544d4144e6b7e144c98d6351b8471 Author: David Tardon <dtar...@redhat.com> Date: Mon Mar 13 19:29:29 2017 +0100 avoid memory leak Change-Id: Iae40d0f17597997d4c44eff0745ca7bbd895856e diff --git a/src/lib/MSPUBParser97.cpp b/src/lib/MSPUBParser97.cpp index 2d717e1..ec99ca2 100644 --- a/src/lib/MSPUBParser97.cpp +++ b/src/lib/MSPUBParser97.cpp @@ -11,6 +11,8 @@ #include <utility> +#include <boost/scoped_ptr.hpp> + #include "MSPUBCollector.h" #include "libmspub_utils.h" #include "MSPUBTypes.h" @@ -36,16 +38,15 @@ unsigned MSPUBParser97::getTextIdOffset() const bool MSPUBParser97::parse() { - librevenge::RVNGInputStream *contents = m_input->getSubStreamByName("Contents"); + boost::scoped_ptr<librevenge::RVNGInputStream> contents(m_input->getSubStreamByName("Contents")); if (!contents) { MSPUB_DEBUG_MSG(("Couldn't get contents stream.\n")); return false; } - if (!parseContents(contents)) + if (!parseContents(contents.get())) { MSPUB_DEBUG_MSG(("Couldn't parse contents stream.\n")); - delete contents; return false; } return m_collector->go(); commit 387fc64586e289ccd972bd6710c4c368b497ef35 Author: David Tardon <dtar...@redhat.com> Date: Mon Mar 13 19:24:40 2017 +0100 the condition is checked in parent makefile Change-Id: I536dc323280f9ac743850e92ce010b1f06e35c3e diff --git a/src/conv/raw/Makefile.am b/src/conv/raw/Makefile.am index 4e4cada..1184461 100644 --- a/src/conv/raw/Makefile.am +++ b/src/conv/raw/Makefile.am @@ -1,5 +1,3 @@ -if BUILD_TOOLS - bin_PROGRAMS = pub2raw AM_CXXFLAGS = -I$(top_srcdir)/inc \ @@ -33,5 +31,3 @@ EXTRA_DIST = \ # These may be in the builddir too BUILD_EXTRA_DIST = \ pub2raw.rc - -endif # BUILD_TOOLS diff --git a/src/conv/svg/Makefile.am b/src/conv/svg/Makefile.am index d9ad4da..07fe792 100644 --- a/src/conv/svg/Makefile.am +++ b/src/conv/svg/Makefile.am @@ -1,5 +1,3 @@ -if BUILD_TOOLS - bin_PROGRAMS = pub2xhtml AM_CXXFLAGS = -I$(top_srcdir)/inc \ @@ -31,5 +29,3 @@ EXTRA_DIST = \ # These may be in the builddir too BUILD_EXTRA_DIST = \ pub2xhtml.rc - -endif # BUILD_TOOLS commit b52e8163973198459fea6e0c73fb16aec66308f3 Author: David Tardon <dtar...@redhat.com> Date: Mon Mar 13 19:24:08 2017 +0100 sources of bin targets are distributed automatically Change-Id: I47cdb009f08f951b8662d7735bbeefbda361e93f diff --git a/src/conv/raw/Makefile.am b/src/conv/raw/Makefile.am index cd45f78..4e4cada 100644 --- a/src/conv/raw/Makefile.am +++ b/src/conv/raw/Makefile.am @@ -28,7 +28,6 @@ if OS_WIN32 endif EXTRA_DIST = \ - $(pub2raw_SOURCES) \ pub2raw.rc.in # These may be in the builddir too diff --git a/src/conv/svg/Makefile.am b/src/conv/svg/Makefile.am index 693f97f..d9ad4da 100644 --- a/src/conv/svg/Makefile.am +++ b/src/conv/svg/Makefile.am @@ -26,7 +26,6 @@ if OS_WIN32 endif EXTRA_DIST = \ - $(pub2xhtml_SOURCES) \ pub2xhtml.rc.in # These may be in the builddir too commit 684eeaaa4855269057d08295a70e5c64f08c91c1 Author: David Tardon <dtar...@redhat.com> Date: Mon Mar 13 19:22:25 2017 +0100 do not hardcode relative path to the lib Change-Id: I43f826b9064f270ed825cba265480ebb760b4cd5 diff --git a/src/conv/raw/Makefile.am b/src/conv/raw/Makefile.am index 6ac2242..cd45f78 100644 --- a/src/conv/raw/Makefile.am +++ b/src/conv/raw/Makefile.am @@ -11,7 +11,7 @@ AM_CXXFLAGS = -I$(top_srcdir)/inc \ pub2raw_DEPENDENCIES = @PUB2RAW_WIN32_RESOURCE@ pub2raw_LDADD = \ - ../../lib/libmspub-@MSPUB_MAJOR_VERSION@.@MSPUB_MINOR_VERSION@.la \ + $(top_builddir)/src/lib/libmspub-@MSPUB_MAJOR_VERSION@.@MSPUB_MINOR_VERSION@.la \ $(REVENGE_GENERATORS_LIBS) \ $(REVENGE_LIBS) \ $(REVENGE_STREAM_LIBS) \ diff --git a/src/conv/svg/Makefile.am b/src/conv/svg/Makefile.am index e0406a0..693f97f 100644 --- a/src/conv/svg/Makefile.am +++ b/src/conv/svg/Makefile.am @@ -10,7 +10,7 @@ AM_CXXFLAGS = -I$(top_srcdir)/inc \ pub2xhtml_DEPENDENCIES = @PUB2XHTML_WIN32_RESOURCE@ pub2xhtml_LDADD = \ - ../../lib/libmspub-@MSPUB_MAJOR_VERSION@.@MSPUB_MINOR_VERSION@.la \ + $(top_builddir)/src/lib/libmspub-@MSPUB_MAJOR_VERSION@.@MSPUB_MINOR_VERSION@.la \ $(REVENGE_LIBS) \ $(REVENGE_STREAM_LIBS) \ @PUB2XHTML_WIN32_RESOURCE@ commit 361e7964fd6fd93884663cb00c1bc1731f91c576 Author: David Tardon <dtar...@redhat.com> Date: Mon Mar 13 19:19:41 2017 +0100 update configure summary Change-Id: I2709e85ab0ff9059af51fadc33f8ecffc9e3c00d diff --git a/configure.ac b/configure.ac index d2abe3d..2242f4d 100644 --- a/configure.ac +++ b/configure.ac @@ -337,7 +337,7 @@ Build configuration: debug: ${enable_debug} docs: ${build_docs} fuzzers: ${enable_fuzzers} - static-tools: ${enable_static_tools} + tools: ${enable_tools} werror: ${enable_werror} ============================================================================== ]) commit da0ac88039262a6dc7a2bbee329e37a7a23e39f6 Author: David Tardon <dtar...@redhat.com> Date: Mon Mar 13 19:05:56 2017 +0100 create a fuzzing driver for oss-fuzz Change-Id: I7636a01885615c109865da923b03682c77e3220d diff --git a/configure.ac b/configure.ac index 7bd436c..d2abe3d 100644 --- a/configure.ac +++ b/configure.ac @@ -52,7 +52,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([--disable-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 ]) @@ -64,7 +76,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 zlib @@ -304,6 +315,7 @@ src/conv/raw/Makefile src/conv/raw/pub2raw.rc src/conv/svg/Makefile src/conv/svg/pub2xhtml.rc +src/fuzz/Makefile src/lib/Makefile src/lib/libmspub.rc inc/Makefile @@ -324,6 +336,7 @@ AC_MSG_NOTICE([ Build configuration: debug: ${enable_debug} docs: ${build_docs} + fuzzers: ${enable_fuzzers} static-tools: ${enable_static_tools} werror: ${enable_werror} ============================================================================== diff --git a/src/Makefile.am b/src/Makefile.am index 64fd45e..c83c78c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,3 +3,7 @@ SUBDIRS = lib if BUILD_TOOLS SUBDIRS += conv endif + +if BUILD_FUZZERS +SUBDIRS += fuzz +endif diff --git a/src/fuzz/.gitignore b/src/fuzz/.gitignore new file mode 100644 index 0000000..f44c6ed --- /dev/null +++ b/src/fuzz/.gitignore @@ -0,0 +1,8 @@ +.deps +.libs +*.lo +*.la +*.o +Makefile +Makefile.in +pubfuzz diff --git a/src/fuzz/Makefile.am b/src/fuzz/Makefile.am new file mode 100644 index 0000000..61b3902 --- /dev/null +++ b/src/fuzz/Makefile.am @@ -0,0 +1,17 @@ +bin_PROGRAMS = pubfuzz + +AM_CXXFLAGS = -I$(top_srcdir)/inc \ + $(REVENGE_GENERATORS_CFLAGS) \ + $(REVENGE_CFLAGS) \ + $(REVENGE_STREAM_LIBS) \ + $(DEBUG_CXXFLAGS) + +pubfuzz_LDADD = \ + $(top_builddir)/src/lib/libmspub-@MSPUB_MAJOR_VERSION@.@MSPUB_MINOR_VERSION@.la \ + $(REVENGE_GENERATORS_LIBS) \ + $(REVENGE_LIBS) \ + $(REVENGE_STREAM_LIBS) \ + -lFuzzingEngine + +pubfuzz_SOURCES = \ + pubfuzz.cpp diff --git a/src/fuzz/pubfuzz.cpp b/src/fuzz/pubfuzz.cpp new file mode 100644 index 0000000..7a9ab5f --- /dev/null +++ b/src/fuzz/pubfuzz.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 <algorithm> +#include <cstdint> + +#include <libmspub/libmspub.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); + libmspub::MSPUBDocument::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