1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <tools/stream.hxx>
11 #include <vcl/FilterConfigItem.hxx>
12 #include <com/sun/star/awt/XToolkit.hpp>
13 #include <com/sun/star/ucb/XContentProvider.hpp>
14 #include <com/sun/star/ucb/XUniversalContentBroker.hpp>
15 #include <libxml/parser.h>
16 #include "commonfuzzer.hxx"
18 extern "C" bool TestPDFExportRTF(SvStream
& rStream
);
20 static void silent_error_func(void*, const char* /*format*/, ...) {}
22 extern "C" int LLVMFuzzerInitialize(int* argc
, char*** argv
)
27 CommonInitialize(argc
, argv
);
29 // initialise unconfigured UCB:
30 css::uno::Reference
<css::ucb::XUniversalContentBroker
> xUcb(
31 comphelper::getProcessServiceFactory()->createInstance(
32 "com.sun.star.ucb.UniversalContentBroker"),
33 css::uno::UNO_QUERY_THROW
);
34 css::uno::Sequence
<css::uno::Any
> aArgs
{ css::uno::Any(OUString("NoConfig")) };
35 css::uno::Reference
<css::ucb::XContentProvider
> xFileProvider(
36 comphelper::getProcessServiceFactory()->createInstanceWithArguments(
37 "com.sun.star.ucb.FileContentProvider", aArgs
),
38 css::uno::UNO_QUERY_THROW
);
39 xUcb
->registerContentProvider(xFileProvider
, "file", true);
41 // create and hold a reference to XToolkit here to avoid the lsan warning about its leak
42 // due to getting created in the unusual case of no vcl main loop
43 static css::uno::Reference
<css::awt::XToolkit
> xTk(
44 comphelper::getProcessServiceFactory()->createInstance("com.sun.star.awt.Toolkit"),
45 css::uno::UNO_QUERY_THROW
);
53 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data
, size_t size
)
55 SvMemoryStream
aStream(const_cast<uint8_t*>(data
), size
, StreamMode::READ
);
56 bool bRTFLoaded
= TestPDFExportRTF(aStream
);
57 // if the rtf didn't load then reject so that input will not be added to the corpus
58 // we're not interested in input that doesn't go on to exercise the pdf export
59 return bRTFLoaded
? 0 : -1;
62 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */