Kaydet (Commit) d8c5cc7c authored tarafından Caolán McNamara's avatar Caolán McNamara

add rtf fuzzer

Change-Id: I36a6294c158232bef8fceeaf5159527f467f5786
üst 6a947848
......@@ -446,7 +446,7 @@ $(foreach ide,\
eclipsecdt,\
$(eval $(call gb_Top_GbuildToIdeIntegrationNS,$(ide))))
fuzzers: Library_sal Library_salhelper Library_reg Library_store Library_unoidl codemaker Library_cppu Library_i18nlangtag Library_cppuhelper Library_comphelper StaticLibrary_ulingu StaticLibrary_findsofficepath Library_tl Library_basegfx Library_canvastools Library_cppcanvas Library_dbtools Library_deploymentmisc Library_deploymentmisc Library_editeng Library_fwe Library_fwi Library_i18nutil Library_localebe1 Library_sax Library_sofficeapp Library_ucbhelper Library_opencl Rdb_services udkapi offapi Library_clew Library_gie Library_icg 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 Executable_giffuzzer Executable_xbmfuzzer Executable_xpmfuzzer Executable_pngfuzzer Executable_bmpfuzzer Executable_svmfuzzer Executable_pcdfuzzer Executable_dxffuzzer Executable_metfuzzer Executable_ppmfuzzer Executable_psdfuzzer Executable_epsfuzzer Executable_pctfuzzer Executable_pcxfuzzer Executable_rasfuzzer Executable_tgafuzzer Executable_tiffuzzer Executable_hwpfuzzer Executable_602fuzzer Executable_lwpfuzzer Executable_olefuzzer AllLangResTarget_sd Executable_pptfuzzer
fuzzers: Library_sal Library_salhelper Library_reg Library_store Library_unoidl codemaker Library_cppu Library_i18nlangtag Library_cppuhelper Library_comphelper StaticLibrary_ulingu StaticLibrary_findsofficepath Library_tl Library_basegfx Library_canvastools Library_cppcanvas Library_dbtools Library_deploymentmisc Library_deploymentmisc Library_editeng Library_fwe Library_fwi Library_i18nutil Library_localebe1 Library_sax Library_sofficeapp Library_ucbhelper Library_opencl Rdb_services udkapi offapi Library_clew Library_gie Library_icg 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 Executable_giffuzzer Executable_xbmfuzzer Executable_xpmfuzzer Executable_pngfuzzer Executable_bmpfuzzer Executable_svmfuzzer Executable_pcdfuzzer Executable_dxffuzzer Executable_metfuzzer Executable_ppmfuzzer Executable_psdfuzzer Executable_epsfuzzer Executable_pctfuzzer Executable_pcxfuzzer Executable_rasfuzzer Executable_tgafuzzer Executable_tiffuzzer Executable_hwpfuzzer Executable_602fuzzer Executable_lwpfuzzer Executable_olefuzzer AllLangResTarget_sd Executable_pptfuzzer Executable_rtffuzzer
endif # MAKE_RESTARTS
......
......@@ -117,6 +117,7 @@ $(eval $(call gb_Helper_register_executables_for_install,OOO,brand, \
$(call gb_Helper_optional,FUZZERS,lwpfuzzer) \
$(call gb_Helper_optional,FUZZERS,olefuzzer) \
$(call gb_Helper_optional,FUZZERS,pptfuzzer) \
$(call gb_Helper_optional,FUZZERS,rtffuzzer) \
$(if $(filter-out ANDROID IOS MACOSX WNT,$(OS)),oosplash) \
soffice_bin \
$(if $(filter DESKTOP,$(BUILD_TYPE)),unopkg_bin) \
......
......@@ -571,6 +571,11 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
sw/source/uibase/app/swmodul1 \
sw/source/uibase/app/swmodule \
sw/source/uibase/app/swwait \
sw/source/uibase/dbui/dbmgr \
sw/source/uibase/dbui/dbui \
sw/source/uibase/dbui/maildispatcher \
sw/source/uibase/dbui/mailmergehelper \
sw/source/uibase/dbui/mmconfigitem \
sw/source/uibase/cctrl/actctrl \
sw/source/uibase/chrdlg/ccoll \
sw/source/uibase/config/StoredChapterNumbering \
......@@ -722,6 +727,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
sw/source/uibase/uno/unodispatch \
sw/source/uibase/uno/unodoc \
sw/source/uibase/uno/unofreg \
sw/source/uibase/uno/unomailmerge \
sw/source/uibase/uno/unomod \
sw/source/uibase/uno/unomodule \
sw/source/uibase/uno/unotxdoc \
......@@ -768,14 +774,8 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
ifneq (,$(filter DBCONNECTIVITY,$(BUILD_TYPE)))
$(eval $(call gb_Library_add_exception_objects,sw,\
sw/source/uibase/dbui/dbmgr \
sw/source/uibase/dbui/dbtree \
sw/source/uibase/dbui/dbui \
sw/source/uibase/dbui/maildispatcher \
sw/source/uibase/dbui/mailmergehelper \
sw/source/uibase/dbui/mailmergetoolbarcontrols \
sw/source/uibase/dbui/mmconfigitem \
sw/source/uibase/uno/unomailmerge \
))
endif
......
......@@ -178,13 +178,13 @@ protected:
#define SW_STORAGE_READER 2
extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportDOC(const OUString &rUrl, const OUString &rFltName);
extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportRTF(const OUString &rUrl);
extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportRTF(SvStream &rStream);
class SW_DLLPUBLIC Reader
{
friend class SwReader;
friend bool TestImportDOC(const OUString &rUrl, const OUString &rFltName);
friend bool TestImportRTF(const OUString &rUrl);
friend bool TestImportRTF(SvStream &rStream);
rtl::Reference<SwDoc> mxTemplate;
OUString aTemplateNm;
......
......@@ -158,10 +158,8 @@ extern "C" SAL_DLLPUBLIC_EXPORT Reader* SAL_CALL ImportRTF()
return new SwRTFReader;
}
extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportRTF(const OUString& rURL)
extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportRTF(SvStream &rStream)
{
SvFileStream aFileStream(rURL, StreamMode::READ);
SwGlobals::ensure();
SfxObjectShellLock xDocSh(new SwDocShell(SfxObjectCreateMode::INTERNAL));
......@@ -177,7 +175,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportRTF(const OUString& rURL
uno::Reference<document::XFilter> xFilter(xInterface, uno::UNO_QUERY_THROW);
uno::Sequence<beans::PropertyValue> aDescriptor(1);
aDescriptor[0].Name = "InputStream";
uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(aFileStream));
uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(rStream));
aDescriptor[0].Value <<= xStream;
bool bRet = true;
try
......
......@@ -241,8 +241,6 @@ void SwModule::StateOther(SfxItemSet &rSet)
// start field dialog
void NewXForms( SfxRequest& rReq ); // implementation: below
#if HAVE_FEATURE_DBCONNECTIVITY
std::shared_ptr<SwMailMergeConfigItem> SwView::EnsureMailMergeConfigItem(const SfxItemSet* pArgs, sal_uInt16 nWizardRestartPage)
{
// create if it does not exist yet
......@@ -305,6 +303,8 @@ std::shared_ptr<SwMailMergeConfigItem> SwView::EnsureMailMergeConfigItem(const S
return xMMConfig;
}
#if HAVE_FEATURE_DBCONNECTIVITY
namespace
{
......
......@@ -101,11 +101,9 @@ class SwView_Impl
mxClipEvtLstnr;
ShellMode eShellMode;
#if HAVE_FEATURE_DBCONNECTIVITY
std::shared_ptr<SwMailMergeConfigItem>
xConfigItem;
sal_uInt16 nMailMergeRestartPage;
#endif
sfx2::DocumentInserter* m_pDocInserter;
SfxRequest* m_pRequest;
......@@ -137,14 +135,12 @@ public:
void AddTransferable(SwTransferable& rTransferable);
#if HAVE_FEATURE_DBCONNECTIVITY
void SetMailMergeConfigItem(std::shared_ptr<SwMailMergeConfigItem>& rItem, sal_uInt16 nRestart)
{
xConfigItem = rItem;
nMailMergeRestartPage = nRestart;
}
std::shared_ptr<SwMailMergeConfigItem> GetMailMergeConfigItem() {return xConfigItem;}
#endif
//#i33307# restore editing position
void SetRestorePosition(const Point& rCursorPos, bool bSelectObj)
......
......@@ -56,9 +56,7 @@ SwView_Impl::SwView_Impl(SwView* pShell)
: mxXTextView()
, pView(pShell)
, eShellMode(ShellMode::Text)
#if HAVE_FEATURE_DBCONNECTIVITY
, nMailMergeRestartPage(0)
#endif
, m_pDocInserter(nullptr)
, m_pRequest(nullptr)
, m_nParam(0)
......
......@@ -131,8 +131,6 @@ void SwView::ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOpt
}
#if HAVE_FEATURE_DBCONNECTIVITY
void SwView::SetMailMergeConfigItem(std::shared_ptr<SwMailMergeConfigItem>& rConfigItem,
sal_uInt16 nRestart)
{
......@@ -145,8 +143,6 @@ std::shared_ptr<SwMailMergeConfigItem> SwView::GetMailMergeConfigItem() const
return m_pViewImpl->GetMailMergeConfigItem();
}
#endif
static bool lcl_IsViewMarks( const SwViewOption& rVOpt )
{
return rVOpt.IsHardBlank() &&
......
......@@ -13,6 +13,6 @@ fuzzer_PYTHONCOMMAND := $(call gb_ExternalExecutable_get_command,python)
fuzzer_Native_cxx=$(call gb_CustomTarget_get_workdir,vcl/workben)/native-code.cxx
$(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 -g draw) > $@
$(call gb_Helper_abbreviate_dirs, $(fuzzer_PYTHONCOMMAND) $(SRCDIR)/solenv/bin/native-code.py -g core -g draw -g writer) > $@
# vim: set noet sw=4 ts=4:
# -*- 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,rtffuzzer))
$(eval $(call gb_Executable_use_api,rtffuzzer,\
offapi \
udkapi \
))
$(eval $(call gb_Executable_use_externals,rtffuzzer,\
$(fuzzer_externals) \
))
$(eval $(call gb_Executable_set_include,rtffuzzer,\
$$(INCLUDE) \
-I$(SRCDIR)/vcl/inc \
))
$(eval $(call gb_Executable_use_libraries,rtffuzzer,\
$(fuzzer_libraries) \
))
$(eval $(call gb_Executable_use_static_libraries,rtffuzzer,\
findsofficepath \
ulingu \
fuzzer \
))
$(eval $(call gb_Executable_add_exception_objects,rtffuzzer,\
vcl/workben/rtffuzzer \
))
$(eval $(call gb_Executable_add_libs,rtffuzzer,\
-lFuzzingEngine \
))
# vim: set noet sw=4 ts=4:
......@@ -129,7 +129,8 @@ $(eval $(call gb_Module_add_targets,vcl,\
Executable_602fuzzer \
Executable_lwpfuzzer \
Executable_olefuzzer \
Executable_pptfuzzer \
Executable_pptfuzzer \
Executable_rtffuzzer \
))
endif
......
......@@ -38,6 +38,11 @@ fuzzer_externals = \
zlib \
fuzzer_libraries = \
msword \
sw \
swd \
writerfilter \
textfd \
sdfilt \
sd \
sdd \
......
......@@ -67,7 +67,6 @@ extern "C" { static void SAL_CALL thisModule() {} }
#endif
typedef bool (*WFilterCall)(const OUString &rUrl, const OUString &rFlt);
typedef bool (*HFilterCall)(const OUString &rUrl);
typedef bool (*FFilterCall)(SvStream &rStream);
/* This constant specifies the number of inputs to process before restarting.
......@@ -349,16 +348,17 @@ try_again:
}
else if (strcmp(argv[2], "rtf") == 0)
{
static HFilterCall pfnImport(nullptr);
static FFilterCall pfnImport(nullptr);
if (!pfnImport)
{
osl::Module aLibrary;
aLibrary.loadRelative(&thisModule, "libmswordlo.so", SAL_LOADMODULE_LAZY);
pfnImport = reinterpret_cast<HFilterCall>(
pfnImport = reinterpret_cast<FFilterCall>(
aLibrary.getFunctionSymbol("TestImportRTF"));
aLibrary.release();
}
ret = (int) (*pfnImport)(out);
SvFileStream aFileStream(out, StreamMode::READ);
ret = (int) (*pfnImport)(aFileStream);
}
else if ( (strcmp(argv[2], "xls") == 0) ||
(strcmp(argv[2], "wb2") == 0) )
......
/* -*- 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 "commonfuzzer.hxx"
extern "C" bool TestImportRTF(SvStream &rStream);
extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
{
TypicalFuzzerInitialize(argc, argv);
return 0;
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
(void)TestImportRTF(aStream);
//fontconfigs alloc mechanism is too complicated for lsan/valgrind so
//force the fontconfig options to be released now, they are demand loaded
//so will be recreated if necessary
SvpSalGraphics::getPlatformGlyphCache().ClearFontOptions();
return 0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment