diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-03-24 11:57:44 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-04-01 20:48:36 +0100 |
commit | d8c5cc7c4bc34436dd95f923dca852b335a5f1e3 (patch) | |
tree | cf6664b002e73a469c23b3a26a9567f434eaa1a4 /vcl/workben | |
parent | 6a9478481c42a717191cc6beb8534e263b98036d (diff) |
add rtf fuzzer
Change-Id: I36a6294c158232bef8fceeaf5159527f467f5786
Diffstat (limited to 'vcl/workben')
-rw-r--r-- | vcl/workben/fftester.cxx | 8 | ||||
-rw-r--r-- | vcl/workben/rtffuzzer.cxx | 33 |
2 files changed, 37 insertions, 4 deletions
diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx index 1dc51e2bdafd..3b7a1619d45e 100644 --- a/vcl/workben/fftester.cxx +++ b/vcl/workben/fftester.cxx @@ -67,7 +67,6 @@ extern "C" { static void SAL_CALL thisModule() {} } #endif typedef bool (*WFilterCall)(const OUString &rUrl, const OUString &rFlt); -typedef bool (*HFilterCall)(const OUString &rUrl); typedef bool (*FFilterCall)(SvStream &rStream); /* This constant specifies the number of inputs to process before restarting. @@ -349,16 +348,17 @@ try_again: } else if (strcmp(argv[2], "rtf") == 0) { - static HFilterCall pfnImport(nullptr); + static FFilterCall pfnImport(nullptr); if (!pfnImport) { osl::Module aLibrary; aLibrary.loadRelative(&thisModule, "libmswordlo.so", SAL_LOADMODULE_LAZY); - pfnImport = reinterpret_cast<HFilterCall>( + pfnImport = reinterpret_cast<FFilterCall>( aLibrary.getFunctionSymbol("TestImportRTF")); aLibrary.release(); } - ret = (int) (*pfnImport)(out); + SvFileStream aFileStream(out, StreamMode::READ); + ret = (int) (*pfnImport)(aFileStream); } else if ( (strcmp(argv[2], "xls") == 0) || (strcmp(argv[2], "wb2") == 0) ) diff --git a/vcl/workben/rtffuzzer.cxx b/vcl/workben/rtffuzzer.cxx new file mode 100644 index 000000000000..88f9b48c8c80 --- /dev/null +++ b/vcl/workben/rtffuzzer.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 TestImportRTF(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)TestImportRTF(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: */ |