add a fodt to pdf fuzzer

Initially give it a fairly tiny input size limit.

Change-Id: Iabc2611174e88f1f6050edb21da4f28694bac4a8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151151
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2023-04-29 20:42:51 +02:00
parent 6b6b83b43f
commit 6c3f27c794
6 changed files with 115 additions and 0 deletions
+1
View File
@@ -144,6 +144,7 @@ $(eval $(call gb_Helper_register_executables_for_install,OOO,brand, \
$(call gb_Helper_optional,FUZZERS,qpwfuzzer) \
$(call gb_Helper_optional,FUZZERS,slkfuzzer) \
$(call gb_Helper_optional,FUZZERS,fodtfuzzer) \
$(call gb_Helper_optional,FUZZERS,fodt2pdffuzzer) \
$(call gb_Helper_optional,FUZZERS,fodsfuzzer) \
$(call gb_Helper_optional,FUZZERS,fodpfuzzer) \
$(call gb_Helper_optional,FUZZERS,xlsfuzzer) \
+1
View File
@@ -153,5 +153,6 @@ curl --no-progress-meter -S \
-C - -O https://dev-www.libreoffice.org/corpus/mtpfuzzer_seed_corpus.zip \
-C - -O https://dev-www.libreoffice.org/corpus/htmlfuzzer_seed_corpus.zip \
-C - -O https://dev-www.libreoffice.org/corpus/zipfuzzer_seed_corpus.zip
cp fodtfuzzer_seed_corpus.zip fodt2pdffuzzer_seed_corpus.zip
echo end downloading dependencies at `date -u`
+50
View File
@@ -0,0 +1,50 @@
# -*- 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,fodt2pdffuzzer))
$(eval $(call gb_Executable_use_api,fodt2pdffuzzer,\
offapi \
udkapi \
))
$(eval $(call gb_Executable_use_externals,fodt2pdffuzzer,\
$(fuzzer_externals) \
epubgen \
revenge \
))
$(eval $(call gb_Executable_set_include,fodt2pdffuzzer,\
$$(INCLUDE) \
-I$(SRCDIR)/vcl/inc \
))
$(eval $(call gb_Executable_use_libraries,fodt2pdffuzzer,\
$(fuzzer_writer_libraries) \
$(fuzzer_core_libraries) \
pdffilter \
))
$(eval $(call gb_Executable_use_static_libraries,fodt2pdffuzzer,\
$(fuzzer_statics) \
fuzzer_writer \
))
$(eval $(call gb_Executable_add_exception_objects,fodt2pdffuzzer,\
vcl/workben/fodt2pdffuzzer \
))
$(eval $(call gb_Executable_add_libs,fodt2pdffuzzer,\
$(LIB_FUZZING_ENGINE) \
))
# vim: set noet sw=4 ts=4:
+1
View File
@@ -177,6 +177,7 @@ $(eval $(call gb_Module_add_targets,vcl,\
Executable_qpwfuzzer \
Executable_slkfuzzer \
Executable_fodtfuzzer \
Executable_fodt2pdffuzzer \
Executable_fodsfuzzer \
Executable_fodpfuzzer \
Executable_xlsfuzzer \
+59
View File
@@ -0,0 +1,59 @@
/* -*- 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 <com/sun/star/awt/XToolkit.hpp>
#include <com/sun/star/ucb/XContentProvider.hpp>
#include <com/sun/star/ucb/XUniversalContentBroker.hpp>
#include "commonfuzzer.hxx"
extern "C" void* SwCreateDialogFactory() { return nullptr; }
extern "C" bool TestPDFExportFODT(SvStream& rStream);
extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
{
if (__lsan_disable)
__lsan_disable();
CommonInitialize(argc, argv);
// initialise unconfigured UCB:
css::uno::Reference<css::ucb::XUniversalContentBroker> xUcb(
comphelper::getProcessServiceFactory()->createInstance(
"com.sun.star.ucb.UniversalContentBroker"),
css::uno::UNO_QUERY_THROW);
css::uno::Sequence<css::uno::Any> aArgs{ css::uno::Any(OUString("NoConfig")) };
css::uno::Reference<css::ucb::XContentProvider> xFileProvider(
comphelper::getProcessServiceFactory()->createInstanceWithArguments(
"com.sun.star.ucb.FileContentProvider", aArgs),
css::uno::UNO_QUERY_THROW);
xUcb->registerContentProvider(xFileProvider, "file", true);
// create and hold a reference to XToolkit here to avoid the lsan warning about its leak
// due to getting created in the unusual case of no vcl main loop
static css::uno::Reference<awt::XToolkit> xTk(
comphelper::getProcessServiceFactory()->createInstance("com.sun.star.awt.Toolkit"),
css::uno::UNO_QUERY_THROW);
if (__lsan_enable)
__lsan_enable();
return 0;
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
(void)TestPDFExportFODT(aStream);
return 0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+3
View File
@@ -0,0 +1,3 @@
[libfuzzer]
max_len = 2048
dict = xml.dict