diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-09-19 10:40:03 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-09-21 09:55:44 +0200 |
commit | 4e302884ce0c05bbfd9b069cb969355d2f30c17d (patch) | |
tree | 4222f3f2ad0e63aec47e07a236ca4941a459a4ee /vcl | |
parent | 81c7311609d5c9b5ebf7348e805276a8864dadcf (diff) |
add fods fuzzer
Change-Id: I3cc5a0d8bb24dd33b63ed82866a4acfb7a2dd043
Reviewed-on: https://gerrit.libreoffice.org/42459
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/Executable_fodsfuzzer.mk | 49 | ||||
-rw-r--r-- | vcl/Module_vcl.mk | 1 | ||||
-rw-r--r-- | vcl/workben/fftester.cxx | 14 | ||||
-rw-r--r-- | vcl/workben/fodsfuzzer.cxx | 33 |
4 files changed, 97 insertions, 0 deletions
diff --git a/vcl/Executable_fodsfuzzer.mk b/vcl/Executable_fodsfuzzer.mk new file mode 100644 index 000000000000..56ff868a7f74 --- /dev/null +++ b/vcl/Executable_fodsfuzzer.mk @@ -0,0 +1,49 @@ +# -*- 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,fodsfuzzer)) + +$(eval $(call gb_Executable_use_api,fodsfuzzer,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_Executable_use_externals,fodsfuzzer,\ + $(fuzzer_externals) \ +)) + +$(eval $(call gb_Executable_set_include,fodsfuzzer,\ + $$(INCLUDE) \ + -I$(SRCDIR)/vcl/inc \ +)) + +$(eval $(call gb_Executable_use_libraries,fodsfuzzer,\ + $(fuzzer_calc_libraries) \ + $(fuzzer_core_libraries) \ +)) + +$(eval $(call gb_Executable_use_static_libraries,fodsfuzzer,\ + findsofficepath \ + ulingu \ + fuzzer_calc \ + fuzzerstubs \ +)) + +$(eval $(call gb_Executable_add_exception_objects,fodsfuzzer,\ + vcl/workben/fodsfuzzer \ +)) + +$(eval $(call gb_Executable_add_libs,fodsfuzzer,\ + -lFuzzingEngine \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk index 0906aab42b33..6cd31572c1c5 100644 --- a/vcl/Module_vcl.mk +++ b/vcl/Module_vcl.mk @@ -138,6 +138,7 @@ $(eval $(call gb_Module_add_targets,vcl,\ Executable_qpwfuzzer \ Executable_slkfuzzer \ Executable_fodtfuzzer \ + Executable_fodsfuzzer \ )) endif diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx index aaf05df5311e..4b9d6979ae54 100644 --- a/vcl/workben/fftester.cxx +++ b/vcl/workben/fftester.cxx @@ -393,6 +393,20 @@ try_again: SvFileStream aFileStream(out, StreamMode::READ); ret = (int) (*pfnImport)(aFileStream); } + else if (strcmp(argv[2], "fods") == 0) + { + static FFilterCall pfnImport(nullptr); + if (!pfnImport) + { + osl::Module aLibrary; + aLibrary.loadRelative(&thisModule, "libsclo.so", SAL_LOADMODULE_LAZY); + pfnImport = reinterpret_cast<FFilterCall>( + aLibrary.getFunctionSymbol("TestImportFODS")); + aLibrary.release(); + } + SvFileStream aFileStream(out, StreamMode::READ); + ret = (int) (*pfnImport)(aFileStream); + } else if (strcmp(argv[2], "xls") == 0) { static WFilterCall pfnImport(nullptr); diff --git a/vcl/workben/fodsfuzzer.cxx b/vcl/workben/fodsfuzzer.cxx new file mode 100644 index 000000000000..b56a8e84f707 --- /dev/null +++ b/vcl/workben/fodsfuzzer.cxx @@ -0,0 +1,33 @@ +/* -*- 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 "commonfuzzer.hxx" + +extern "C" bool TestImportFODS(SvStream &rStream); + +extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) +{ + TypicalFuzzerInitialize(argc, argv); + return 0; +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ); + (void)TestImportFODS(aStream); + //fontconfigs alloc mechanism is too complicated for lsan/valgrind so + //force the fontconfig options to be released now, they are demand loaded + //so will be recreated if necessary + SvpSalGraphics::getPlatformGlyphCache().ClearFontOptions(); + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |