diff options
-rw-r--r-- | Repository.mk | 1 | ||||
-rwxr-xr-x | bin/oss-fuzz-setup.sh | 1 | ||||
-rw-r--r-- | vcl/Executable_fodt2pdffuzzer.mk | 50 | ||||
-rw-r--r-- | vcl/Module_vcl.mk | 1 | ||||
-rw-r--r-- | vcl/workben/fodt2pdffuzzer.cxx | 59 | ||||
-rw-r--r-- | vcl/workben/fodt2pdffuzzer.options | 3 |
6 files changed, 115 insertions, 0 deletions
diff --git a/Repository.mk b/Repository.mk index 1b2664c76e5d..bf576683389a 100644 --- a/Repository.mk +++ b/Repository.mk @@ -144,6 +144,7 @@ $(eval $(call gb_Helper_register_executables_for_install,OOO,brand, \ $(call gb_Helper_optional,FUZZERS,qpwfuzzer) \ $(call gb_Helper_optional,FUZZERS,slkfuzzer) \ $(call gb_Helper_optional,FUZZERS,fodtfuzzer) \ + $(call gb_Helper_optional,FUZZERS,fodt2pdffuzzer) \ $(call gb_Helper_optional,FUZZERS,fodsfuzzer) \ $(call gb_Helper_optional,FUZZERS,fodpfuzzer) \ $(call gb_Helper_optional,FUZZERS,xlsfuzzer) \ diff --git a/bin/oss-fuzz-setup.sh b/bin/oss-fuzz-setup.sh index 9268e39c4b06..3e27957d8d91 100755 --- a/bin/oss-fuzz-setup.sh +++ b/bin/oss-fuzz-setup.sh @@ -153,5 +153,6 @@ curl --no-progress-meter -S \ -C - -O https://dev-www.libreoffice.org/corpus/mtpfuzzer_seed_corpus.zip \ -C - -O https://dev-www.libreoffice.org/corpus/htmlfuzzer_seed_corpus.zip \ -C - -O https://dev-www.libreoffice.org/corpus/zipfuzzer_seed_corpus.zip +cp fodtfuzzer_seed_corpus.zip fodt2pdffuzzer_seed_corpus.zip echo end downloading dependencies at `date -u` diff --git a/vcl/Executable_fodt2pdffuzzer.mk b/vcl/Executable_fodt2pdffuzzer.mk new file mode 100644 index 000000000000..d4ba9f666519 --- /dev/null +++ b/vcl/Executable_fodt2pdffuzzer.mk @@ -0,0 +1,50 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# +# This file is part of the LibreOffice 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 $(SRCDIR)/vcl/commonfuzzer.mk + +$(eval $(call gb_Executable_Executable,fodt2pdffuzzer)) + +$(eval $(call gb_Executable_use_api,fodt2pdffuzzer,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_Executable_use_externals,fodt2pdffuzzer,\ + $(fuzzer_externals) \ + epubgen \ + revenge \ +)) + +$(eval $(call gb_Executable_set_include,fodt2pdffuzzer,\ + $$(INCLUDE) \ + -I$(SRCDIR)/vcl/inc \ +)) + +$(eval $(call gb_Executable_use_libraries,fodt2pdffuzzer,\ + $(fuzzer_writer_libraries) \ + $(fuzzer_core_libraries) \ + pdffilter \ +)) + +$(eval $(call gb_Executable_use_static_libraries,fodt2pdffuzzer,\ + $(fuzzer_statics) \ + fuzzer_writer \ +)) + +$(eval $(call gb_Executable_add_exception_objects,fodt2pdffuzzer,\ + vcl/workben/fodt2pdffuzzer \ +)) + +$(eval $(call gb_Executable_add_libs,fodt2pdffuzzer,\ + $(LIB_FUZZING_ENGINE) \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk index b8728a8529e4..5265cd951243 100644 --- a/vcl/Module_vcl.mk +++ b/vcl/Module_vcl.mk @@ -177,6 +177,7 @@ $(eval $(call gb_Module_add_targets,vcl,\ Executable_qpwfuzzer \ Executable_slkfuzzer \ Executable_fodtfuzzer \ + Executable_fodt2pdffuzzer \ Executable_fodsfuzzer \ Executable_fodpfuzzer \ Executable_xlsfuzzer \ diff --git a/vcl/workben/fodt2pdffuzzer.cxx b/vcl/workben/fodt2pdffuzzer.cxx new file mode 100644 index 000000000000..a80d24dd25a7 --- /dev/null +++ b/vcl/workben/fodt2pdffuzzer.cxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice 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 <tools/stream.hxx> +#include <vcl/FilterConfigItem.hxx> +#include <com/sun/star/awt/XToolkit.hpp> +#include <com/sun/star/ucb/XContentProvider.hpp> +#include <com/sun/star/ucb/XUniversalContentBroker.hpp> +#include "commonfuzzer.hxx" + +extern "C" void* SwCreateDialogFactory() { return nullptr; } + +extern "C" bool TestPDFExportFODT(SvStream& rStream); + +extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) +{ + if (__lsan_disable) + __lsan_disable(); + + CommonInitialize(argc, argv); + + // initialise unconfigured UCB: + css::uno::Reference<css::ucb::XUniversalContentBroker> xUcb( + comphelper::getProcessServiceFactory()->createInstance( + "com.sun.star.ucb.UniversalContentBroker"), + css::uno::UNO_QUERY_THROW); + css::uno::Sequence<css::uno::Any> aArgs{ css::uno::Any(OUString("NoConfig")) }; + css::uno::Reference<css::ucb::XContentProvider> xFileProvider( + comphelper::getProcessServiceFactory()->createInstanceWithArguments( + "com.sun.star.ucb.FileContentProvider", aArgs), + css::uno::UNO_QUERY_THROW); + xUcb->registerContentProvider(xFileProvider, "file", true); + + // create and hold a reference to XToolkit here to avoid the lsan warning about its leak + // due to getting created in the unusual case of no vcl main loop + static css::uno::Reference<awt::XToolkit> xTk( + comphelper::getProcessServiceFactory()->createInstance("com.sun.star.awt.Toolkit"), + css::uno::UNO_QUERY_THROW); + + if (__lsan_enable) + __lsan_enable(); + + return 0; +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ); + (void)TestPDFExportFODT(aStream); + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/workben/fodt2pdffuzzer.options b/vcl/workben/fodt2pdffuzzer.options new file mode 100644 index 000000000000..1ae5aaff4b14 --- /dev/null +++ b/vcl/workben/fodt2pdffuzzer.options @@ -0,0 +1,3 @@ +[libfuzzer] +max_len = 2048 +dict = xml.dict |