diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-12-30 15:30:20 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-01-02 20:36:13 +0000 |
commit | 85e8507d19195387784ba6af42d91609b129e00d (patch) | |
tree | 7becdfed97aa7c8abe37d4194046ba9cf2532b4f /vcl/workben/wmffuzzer.cxx | |
parent | tdf#95416 Get rid of #include ../foo/bar.hxx style includes (diff) | |
download | core-85e8507d19195387784ba6af42d91609b129e00d.tar.gz core-85e8507d19195387784ba6af42d91609b129e00d.zip |
add a jpg fuzzer
reshuffle things to share common core
Change-Id: I50aa0e2ddeefaa4b2d0592b1118defd28b7347db
Diffstat (limited to 'vcl/workben/wmffuzzer.cxx')
-rw-r--r-- | vcl/workben/wmffuzzer.cxx | 85 |
1 files changed, 3 insertions, 82 deletions
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) { |