summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.in2
-rw-r--r--Repository.mk1
-rw-r--r--vcl/CustomTarget_nativecode.mk8
-rw-r--r--vcl/Executable_jpgfuzzer.mk47
-rw-r--r--vcl/Executable_wmffuzzer.mk92
-rw-r--r--vcl/Module_vcl.mk2
-rw-r--r--vcl/StaticLibrary_fuzzer.mk47
-rw-r--r--vcl/commonfuzzer.mk77
-rw-r--r--vcl/workben/commonfuzzer.hxx94
-rw-r--r--vcl/workben/jpgfuzzer.cxx22
-rw-r--r--vcl/workben/wmffuzzer.cxx85
11 files changed, 303 insertions, 174 deletions
diff --git a/Makefile.in b/Makefile.in
index 5c269f0b5a8f..43fd5e9353dc 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -424,7 +424,7 @@ $(foreach ide,\
eclipsecdt,\
$(eval $(call gb_Top_GbuildToIdeIntegration,$(ide))))
-fuzzers: Library_sal Library_salhelper Library_reg Library_store Library_unoidl codemaker Library_cppu Library_i18nlangtag Library_cppuhelper Library_comphelper StaticLibrary_ulingu StaticLibrary_jpeg StaticLibrary_findsofficepath Library_tl Rdb_services udkapi offapi Library_clew Library_gie Library_reflection Library_invocadapt Library_bootstrap Library_introspection Library_stocservices Library_xmlreader Library_gcc3_uno instsetoo_native more_fonts Executable_wmffuzzer
+fuzzers: Library_sal Library_salhelper Library_reg Library_store Library_unoidl codemaker Library_cppu Library_i18nlangtag Library_cppuhelper Library_comphelper StaticLibrary_ulingu StaticLibrary_jpeg StaticLibrary_findsofficepath Library_tl Rdb_services udkapi offapi Library_clew Library_gie Library_reflection Library_invocadapt Library_bootstrap Library_introspection Library_stocservices Library_xmlreader Library_gcc3_uno instsetoo_native more_fonts StaticLibrary_fuzzer Executable_wmffuzzer Executable_jpgfuzzer
endif # MAKE_RESTARTS
diff --git a/Repository.mk b/Repository.mk
index dbc3c2bc5a25..8e296ecc399b 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -94,6 +94,7 @@ $(eval $(call gb_Helper_register_executables_for_install,SDK,sdk, \
$(eval $(call gb_Helper_register_executables_for_install,OOO,brand, \
$(call gb_Helper_optional,BREAKPAD,minidump_upload) \
$(call gb_Helper_optional,FUZZERS,wmffuzzer) \
+ $(call gb_Helper_optional,FUZZERS,jpgfuzzer) \
$(if $(filter-out ANDROID IOS MACOSX WNT,$(OS)),oosplash) \
soffice_bin \
$(if $(filter DESKTOP,$(BUILD_TYPE)),unopkg_bin) \
diff --git a/vcl/CustomTarget_nativecode.mk b/vcl/CustomTarget_nativecode.mk
index debd9ef09de5..115b0a7adb87 100644
--- a/vcl/CustomTarget_nativecode.mk
+++ b/vcl/CustomTarget_nativecode.mk
@@ -8,11 +8,11 @@
$(eval $(call gb_CustomTarget_CustomTarget,vcl/workben))
-wmffuzzer_PYTHONCOMMAND := $(call gb_ExternalExecutable_get_command,python)
+fuzzer_PYTHONCOMMAND := $(call gb_ExternalExecutable_get_command,python)
-wmffuzzer_Native_cxx=$(call gb_CustomTarget_get_workdir,vcl/workben)/native-code.cxx
+fuzzer_Native_cxx=$(call gb_CustomTarget_get_workdir,vcl/workben)/native-code.cxx
-$(wmffuzzer_Native_cxx): $(SRCDIR)/solenv/bin/native-code.py | $(call gb_CustomTarget_get_workdir,vcl/workben)/.dir
- $(call gb_Helper_abbreviate_dirs, $(wmffuzzer_PYTHONCOMMAND) $(SRCDIR)/solenv/bin/native-code.py -g core) > $@
+$(fuzzer_Native_cxx): $(SRCDIR)/solenv/bin/native-code.py | $(call gb_CustomTarget_get_workdir,vcl/workben)/.dir
+ $(call gb_Helper_abbreviate_dirs, $(fuzzer_PYTHONCOMMAND) $(SRCDIR)/solenv/bin/native-code.py -g core) > $@
# vim: set noet sw=4 ts=4:
diff --git a/vcl/Executable_jpgfuzzer.mk b/vcl/Executable_jpgfuzzer.mk
new file mode 100644
index 000000000000..d077dce4b195
--- /dev/null
+++ b/vcl/Executable_jpgfuzzer.mk
@@ -0,0 +1,47 @@
+# -*- 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,jpgfuzzer))
+
+$(eval $(call gb_Executable_use_api,jpgfuzzer,\
+ offapi \
+ udkapi \
+))
+
+$(eval $(call gb_Executable_use_externals,jpgfuzzer,\
+ $(fuzzer_externals) \
+))
+
+$(eval $(call gb_Executable_set_include,jpgfuzzer,\
+ $$(INCLUDE) \
+ -I$(SRCDIR)/vcl/inc \
+))
+
+$(eval $(call gb_Executable_use_libraries,jpgfuzzer,\
+ $(fuzzer_libraries) \
+))
+
+$(eval $(call gb_Executable_use_static_libraries,jpgfuzzer,\
+ findsofficepath \
+ ulingu \
+ fuzzer \
+))
+
+$(eval $(call gb_Executable_add_exception_objects,jpgfuzzer,\
+ vcl/workben/jpgfuzzer \
+))
+
+$(eval $(call gb_Executable_add_libs,jpgfuzzer,\
+ -lFuzzingEngine \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/vcl/Executable_wmffuzzer.mk b/vcl/Executable_wmffuzzer.mk
index 0a73f779752e..22feb6a40e55 100644
--- a/vcl/Executable_wmffuzzer.mk
+++ b/vcl/Executable_wmffuzzer.mk
@@ -8,6 +8,8 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
+include $(SRCDIR)/vcl/commonfuzzer.mk
+
$(eval $(call gb_Executable_Executable,wmffuzzer))
$(eval $(call gb_Executable_use_api,wmffuzzer,\
@@ -16,28 +18,7 @@ $(eval $(call gb_Executable_use_api,wmffuzzer,\
))
$(eval $(call gb_Executable_use_externals,wmffuzzer,\
- boost_headers \
- curl \
- harfbuzz \
- graphite \
- cairo \
- fontconfig \
- freetype \
- icui18n \
- icuuc \
- icudata \
- lcms2 \
- librdf \
- libxslt \
- libxml2 \
- jpeg \
- clew \
- openssl \
- expat \
- mythes \
- hyphen \
- hunspell \
- zlib \
+ $(fuzzer_externals) \
))
$(eval $(call gb_Executable_set_include,wmffuzzer,\
@@ -46,80 +27,17 @@ $(eval $(call gb_Executable_set_include,wmffuzzer,\
))
$(eval $(call gb_Executable_use_libraries,wmffuzzer,\
- basctl \
- merged \
- cui \
- chartcontroller \
- chartcore \
- sm \
- gie \
- oox \
- reflection \
- odfflatxml \
- invocadapt \
- bootstrap \
- introspection \
- stocservices \
- lnth \
- hyphen \
- i18nsearch \
- embobj \
- evtatt \
- unordf \
- ucphier1 \
- ucptdoc1 \
- srtrs1 \
- storagefd \
- mtfrenderer \
- canvasfactory \
- vclcanvas \
- xof \
- xmlfa \
- xmlfd \
- cppu \
- cppuhelper \
- comphelper \
- i18nlangtag \
- xmlreader \
- unoidl \
- reg \
- store \
- expwrap \
- gcc3_uno \
- salhelper \
- sal \
+ $(fuzzer_libraries) \
))
$(eval $(call gb_Executable_use_static_libraries,wmffuzzer,\
findsofficepath \
ulingu \
+ fuzzer \
))
$(eval $(call gb_Executable_add_exception_objects,wmffuzzer,\
vcl/workben/wmffuzzer \
- vcl/workben/localestub/localestub \
- vcl/workben/localestub/localedata_en_AU \
- vcl/workben/localestub/localedata_en_BW \
- vcl/workben/localestub/localedata_en_BZ \
- vcl/workben/localestub/localedata_en_CA \
- vcl/workben/localestub/localedata_en_GB \
- vcl/workben/localestub/localedata_en_GH \
- vcl/workben/localestub/localedata_en_GM \
- vcl/workben/localestub/localedata_en_IE \
- vcl/workben/localestub/localedata_en_IN \
- vcl/workben/localestub/localedata_en_JM \
- vcl/workben/localestub/localedata_en_MW \
- vcl/workben/localestub/localedata_en_NA \
- vcl/workben/localestub/localedata_en_NZ \
- vcl/workben/localestub/localedata_en_PH \
- vcl/workben/localestub/localedata_en_TT \
- vcl/workben/localestub/localedata_en_US \
- vcl/workben/localestub/localedata_en_ZA \
- vcl/workben/localestub/localedata_en_ZW \
-))
-
-$(eval $(call gb_Executable_add_generated_exception_objects,wmffuzzer,\
- CustomTarget/vcl/workben/native-code \
))
$(eval $(call gb_Executable_add_libs,wmffuzzer,\
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index 7e6b444fb7c2..a9b91eb12493 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -105,7 +105,9 @@ endif
ifneq ($(ENABLE_FUZZERS),)
$(eval $(call gb_Module_add_targets,vcl,\
CustomTarget_nativecode \
+ StaticLibrary_fuzzer \
Executable_wmffuzzer \
+ Executable_jpgfuzzer \
))
endif
diff --git a/vcl/StaticLibrary_fuzzer.mk b/vcl/StaticLibrary_fuzzer.mk
new file mode 100644
index 000000000000..8e896ef8e53b
--- /dev/null
+++ b/vcl/StaticLibrary_fuzzer.mk
@@ -0,0 +1,47 @@
+# -*- 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/.
+
+$(eval $(call gb_StaticLibrary_StaticLibrary,fuzzer))
+
+$(eval $(call gb_StaticLibrary_set_include,fuzzer,\
+ $$(INCLUDE) \
+ -I$(SRCDIR)/vcl/inc \
+))
+
+$(eval $(call gb_StaticLibrary_use_api,fuzzer,\
+ offapi \
+ udkapi \
+))
+
+$(eval $(call gb_StaticLibrary_add_exception_objects,fuzzer,\
+ vcl/workben/localestub/localestub \
+ vcl/workben/localestub/localedata_en_AU \
+ vcl/workben/localestub/localedata_en_BW \
+ vcl/workben/localestub/localedata_en_BZ \
+ vcl/workben/localestub/localedata_en_CA \
+ vcl/workben/localestub/localedata_en_GB \
+ vcl/workben/localestub/localedata_en_GH \
+ vcl/workben/localestub/localedata_en_GM \
+ vcl/workben/localestub/localedata_en_IE \
+ vcl/workben/localestub/localedata_en_IN \
+ vcl/workben/localestub/localedata_en_JM \
+ vcl/workben/localestub/localedata_en_MW \
+ vcl/workben/localestub/localedata_en_NA \
+ vcl/workben/localestub/localedata_en_NZ \
+ vcl/workben/localestub/localedata_en_PH \
+ vcl/workben/localestub/localedata_en_TT \
+ vcl/workben/localestub/localedata_en_US \
+ vcl/workben/localestub/localedata_en_ZA \
+ vcl/workben/localestub/localedata_en_ZW \
+))
+
+$(eval $(call gb_StaticLibrary_add_generated_exception_objects,fuzzer,\
+ CustomTarget/vcl/workben/native-code \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/vcl/commonfuzzer.mk b/vcl/commonfuzzer.mk
new file mode 100644
index 000000000000..3d2125f2227a
--- /dev/null
+++ b/vcl/commonfuzzer.mk
@@ -0,0 +1,77 @@
+# -*- 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/.
+#
+
+fuzzer_externals = \
+ boost_headers \
+ curl \
+ harfbuzz \
+ graphite \
+ cairo \
+ fontconfig \
+ freetype \
+ icui18n \
+ icuuc \
+ icudata \
+ lcms2 \
+ librdf \
+ libxslt \
+ libxml2 \
+ jpeg \
+ clew \
+ openssl \
+ expat \
+ mythes \
+ hyphen \
+ hunspell \
+ zlib \
+
+fuzzer_libraries = \
+ basctl \
+ merged \
+ cui \
+ chartcontroller \
+ chartcore \
+ sm \
+ gie \
+ oox \
+ reflection \
+ odfflatxml \
+ invocadapt \
+ bootstrap \
+ introspection \
+ stocservices \
+ lnth \
+ hyphen \
+ i18nsearch \
+ embobj \
+ evtatt \
+ unordf \
+ ucphier1 \
+ ucptdoc1 \
+ srtrs1 \
+ storagefd \
+ mtfrenderer \
+ canvasfactory \
+ vclcanvas \
+ xof \
+ xmlfa \
+ xmlfd \
+ cppu \
+ cppuhelper \
+ comphelper \
+ i18nlangtag \
+ xmlreader \
+ unoidl \
+ reg \
+ store \
+ expwrap \
+ gcc3_uno \
+ salhelper \
+ sal \
diff --git a/vcl/workben/commonfuzzer.hxx b/vcl/workben/commonfuzzer.hxx
new file mode 100644
index 000000000000..715d69144b07
--- /dev/null
+++ b/vcl/workben/commonfuzzer.hxx
@@ -0,0 +1,94 @@
+/* -*- 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 <sal/main.h>
+#include <tools/extendapplicationenvironment.hxx>
+
+#include <cppuhelper/bootstrap.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <unotools/configmgr.hxx>
+#include <rtl/strbuf.hxx>
+#include <osl/file.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/wmf.hxx>
+#include <unistd.h>
+#include <stdlib.h>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace cppu;
+
+namespace
+{
+ void setFontConfigConf()
+ {
+ osl::File aFontConfig("file:///tmp/wmffuzzerfonts.conf");
+ if (aFontConfig.open(osl_File_OpenFlag_Create | osl_File_OpenFlag_Write) == osl::File::E_None)
+ {
+ OUString uri;
+ if (osl_getExecutableFile(&uri.pData) != osl_Process_E_None) {
+ abort();
+ }
+ sal_Int32 lastDirSeperatorPos = uri.lastIndexOf('/');
+ if (lastDirSeperatorPos >= 0) {
+ uri = uri.copy(0, lastDirSeperatorPos + 1);
+ }
+ OUString path;
+ osl::FileBase::getSystemPathFromFileURL(uri, path);
+ OString sFontDir = OUStringToOString(path, osl_getThreadTextEncoding());
+
+ rtl::OStringBuffer aBuffer("<?xml version=\"1.0\"?>\n<fontconfig><dir>");
+ aBuffer.append(sFontDir);
+ aBuffer.append("</dir><cachedir>/tmp/cache/fontconfig</cachedir></fontconfig>");
+ rtl::OString aConf = aBuffer.makeStringAndClear();
+ sal_uInt64 aBytesWritten;
+ aFontConfig.write(aConf.getStr(), aConf.getLength(), aBytesWritten);
+ assert(aBytesWritten == aConf.getLength());
+ }
+ setenv("FONTCONFIG_FILE", "/tmp/wmffuzzerfonts.conf", 0);
+ }
+}
+
+extern "C"
+{
+ __attribute__((weak)) void __lsan_disable();
+ __attribute__((weak)) void __lsan_enable();
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ if (__lsan_disable)
+ __lsan_disable();
+
+ setenv("SAL_USE_VCLPLUGIN", "svp", 1);
+
+ osl_setCommandArgs(*argc, *argv);
+
+ setFontConfigConf();
+
+ tools::extendApplicationEnvironment();
+
+ Reference< XComponentContext > xContext = defaultBootstrap_InitialComponentContext();
+ Reference< XMultiServiceFactory > xServiceManager( xContext->getServiceManager(), UNO_QUERY );
+ if( !xServiceManager.is() )
+ Application::Abort( "Failed to bootstrap" );
+ comphelper::setProcessServiceFactory( xServiceManager );
+ utl::ConfigManager::EnableAvoidConfig();
+ InitVCL();
+
+ if (__lsan_enable)
+ __lsan_enable();
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/jpgfuzzer.cxx b/vcl/workben/jpgfuzzer.cxx
new file mode 100644
index 000000000000..429401afe9bf
--- /dev/null
+++ b/vcl/workben/jpgfuzzer.cxx
@@ -0,0 +1,22 @@
+/* -*- 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 <../source/filter/jpeg/jpeg.hxx>
+#include "commonfuzzer.hxx"
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ Graphic aGraphic;
+ (void)ImportJPEG(aStream, aGraphic, nullptr, GraphicFilterImportFlags::NONE);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/wmffuzzer.cxx b/vcl/workben/wmffuzzer.cxx
index 192573ad4b03..8b5054e9070a 100644
--- a/vcl/workben/wmffuzzer.cxx
+++ b/vcl/workben/wmffuzzer.cxx
@@ -7,89 +7,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <sal/main.h>
-#include <tools/extendapplicationenvironment.hxx>
-
-#include <cppuhelper/bootstrap.hxx>
-#include <comphelper/processfactory.hxx>
-
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <unotools/configmgr.hxx>
-#include <rtl/strbuf.hxx>
-#include <osl/file.hxx>
-#include <vcl/svapp.hxx>
+#include <tools/stream.hxx>
+#include <vcl/gdimtf.hxx>
#include <vcl/wmf.hxx>
-#include <unistd.h>
-#include <stdlib.h>
-
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::lang;
-using namespace cppu;
-
-namespace
-{
- void setFontConfigConf()
- {
- osl::File aFontConfig("file:///tmp/wmffuzzerfonts.conf");
- if (aFontConfig.open(osl_File_OpenFlag_Create | osl_File_OpenFlag_Write) == osl::File::E_None)
- {
- OUString uri;
- if (osl_getExecutableFile(&uri.pData) != osl_Process_E_None) {
- abort();
- }
- sal_Int32 lastDirSeperatorPos = uri.lastIndexOf('/');
- if (lastDirSeperatorPos >= 0) {
- uri = uri.copy(0, lastDirSeperatorPos + 1);
- }
- OUString path;
- osl::FileBase::getSystemPathFromFileURL(uri, path);
- OString sFontDir = OUStringToOString(path, osl_getThreadTextEncoding());
-
- rtl::OStringBuffer aBuffer("<?xml version=\"1.0\"?>\n<fontconfig><dir>");
- aBuffer.append(sFontDir);
- aBuffer.append("</dir><cachedir>/tmp/cache/fontconfig</cachedir></fontconfig>");
- rtl::OString aConf = aBuffer.makeStringAndClear();
- sal_uInt64 aBytesWritten;
- aFontConfig.write(aConf.getStr(), aConf.getLength(), aBytesWritten);
- assert(aBytesWritten == aConf.getLength());
- }
- setenv("FONTCONFIG_FILE", "/tmp/wmffuzzerfonts.conf", 0);
- }
-}
-
-extern "C"
-{
- __attribute__((weak)) void __lsan_disable();
- __attribute__((weak)) void __lsan_enable();
-}
-
-extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
-{
- if (__lsan_disable)
- __lsan_disable();
-
- setenv("SAL_USE_VCLPLUGIN", "svp", 1);
-
- osl_setCommandArgs(*argc, *argv);
-
- setFontConfigConf();
-
- tools::extendApplicationEnvironment();
-
- Reference< XComponentContext > xContext = defaultBootstrap_InitialComponentContext();
- Reference< XMultiServiceFactory > xServiceManager( xContext->getServiceManager(), UNO_QUERY );
- if( !xServiceManager.is() )
- Application::Abort( "Failed to bootstrap" );
- comphelper::setProcessServiceFactory( xServiceManager );
- utl::ConfigManager::EnableAvoidConfig();
- InitVCL();
-
- if (__lsan_enable)
- __lsan_enable();
-
- return 0;
-}
+#include "commonfuzzer.hxx"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{