summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-12-07 13:40:53 +0000
committerCaolán McNamara <caolanm@redhat.com>2016-12-07 13:41:30 +0000
commitb1955cced2e63710b67cd9d4f8392333dbfdf667 (patch)
treee6e5cb5e74f53d4c223745a4b3be6bca22a52ec2 /vcl
parent61b00192cd4682cb592d880be1f4d57925ca03c7 (diff)
oss-fuzz: provide a way to init fontconfig with minimal fonts
Change-Id: Ic63788318d24fc01a38331a3567ccd67b1b8885f
Diffstat (limited to 'vcl')
-rw-r--r--vcl/workben/wmffuzzer.cxx21
1 files changed, 21 insertions, 0 deletions
diff --git a/vcl/workben/wmffuzzer.cxx b/vcl/workben/wmffuzzer.cxx
index ac834cc61401..ca9293e50db0 100644
--- a/vcl/workben/wmffuzzer.cxx
+++ b/vcl/workben/wmffuzzer.cxx
@@ -16,6 +16,7 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <unotools/configmgr.hxx>
+#include <osl/file.hxx>
#include <vcl/svapp.hxx>
#include <vcl/wmf.hxx>
#include <unistd.h>
@@ -25,9 +26,29 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace cppu;
+namespace
+{
+ void setFontConfigConf()
+ {
+ 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 sFontConf = OUStringToOString(path, osl_getThreadTextEncoding()) + "fonts.conf";
+ setenv("FONTCONFIG_FILE", sFontConf.getStr(), 0);
+ }
+}
+
extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
{
setenv("SAL_USE_VCLPLUGIN", "svp", 1);
+ setFontConfigConf();
osl_setCommandArgs(*argc, *argv);