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

add a jpg fuzzer

reshuffle things to share common core

Change-Id: I50aa0e2ddeefaa4b2d0592b1118defd28b7347db
üst f6ff601b
......@@ -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
......
......@@ -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) \
......
......@@ -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:
# -*- 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:
......@@ -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,\
......
......@@ -105,7 +105,9 @@ endif
ifneq ($(ENABLE_FUZZERS),)
$(eval $(call gb_Module_add_targets,vcl,\
CustomTarget_nativecode \
StaticLibrary_fuzzer \
Executable_wmffuzzer \
Executable_jpgfuzzer \
))
endif
......
# -*- 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:
# -*- 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 \
/* -*- 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: */
/* -*- 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: */
......@@ -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)
{
......
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