summaryrefslogtreecommitdiff
path: root/vcl/workben
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-02-23 10:30:17 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-02-24 14:04:58 +0000
commit40e55cf24dd30acd6d928cd764bc597dd11f5fad (patch)
tree9e96cacd218e2e67178ff78e5ce2c84604457167 /vcl/workben
parent71a84b69ae30458a941f38869aa994118051a063 (diff)
add hwp fuzzer
Change-Id: I07fe351a182328f9ef98cb9866529637a6688c64 Reviewed-on: https://gerrit.libreoffice.org/34570 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/workben')
-rw-r--r--vcl/workben/fftester.cxx8
-rw-r--r--vcl/workben/hwpfuzzer.cxx23
2 files changed, 28 insertions, 3 deletions
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<HFilterCall>(
+ pfnImport = reinterpret_cast<FFilterCall>(
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 <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+
+extern "C" bool TestImportHWP(SvStream &rStream);
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportHWP(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */