From 40e55cf24dd30acd6d928cd764bc597dd11f5fad Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 23 Feb 2017 10:30:17 +0000 Subject: add hwp fuzzer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I07fe351a182328f9ef98cb9866529637a6688c64 Reviewed-on: https://gerrit.libreoffice.org/34570 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- vcl/workben/fftester.cxx | 8 +++++--- vcl/workben/hwpfuzzer.cxx | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 vcl/workben/hwpfuzzer.cxx (limited to 'vcl/workben') diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx index d1b9cf0ef7d1..088d08810d2c 100644 --- a/vcl/workben/fftester.cxx +++ b/vcl/workben/fftester.cxx @@ -68,6 +68,7 @@ extern "C" { static void SAL_CALL thisModule() {} } 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. * This is optional, but helps limit the impact of memory leaks and similar @@ -404,16 +405,17 @@ try_again: } else if (strcmp(argv[2], "hwp") == 0) { - static HFilterCall pfnImport(nullptr); + static FFilterCall pfnImport(nullptr); if (!pfnImport) { osl::Module aLibrary; aLibrary.loadRelative(&thisModule, "libhwplo.so", SAL_LOADMODULE_LAZY); - pfnImport = reinterpret_cast( + pfnImport = reinterpret_cast( aLibrary.getFunctionSymbol("TestImportHWP")); aLibrary.release(); } - ret = (int) (*pfnImport)(out); + SvFileStream aFileStream(out, StreamMode::READ); + ret = (int) (*pfnImport)(aFileStream); } else if (strcmp(argv[2], "602") == 0) { diff --git a/vcl/workben/hwpfuzzer.cxx b/vcl/workben/hwpfuzzer.cxx new file mode 100644 index 000000000000..49ee3dc330f7 --- /dev/null +++ b/vcl/workben/hwpfuzzer.cxx @@ -0,0 +1,23 @@ +/* -*- 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 +#include +#include "commonfuzzer.hxx" + +extern "C" bool TestImportHWP(SvStream &rStream); + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + SvMemoryStream aStream(const_cast(data), size, StreamMode::READ); + (void)TestImportHWP(aStream); + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3