summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-11-28 16:56:41 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-11-30 10:00:30 +0100
commit08f7ff03652517aa83dbc9558fd542bdf0000b7f (patch)
tree5dd4314a0a365713662b5cd33c66a8faaeb008af /vcl
parentbfefe2ce8ca1b4a25ede09886ce24d57695f8d3e (diff)
add xlsx fuzzer
Change-Id: Icce1317dc3ccfb598ce07ee61eddd873f1f98222 Reviewed-on: https://gerrit.libreoffice.org/45481 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')
-rw-r--r--vcl/Executable_xlsxfuzzer.mk49
-rw-r--r--vcl/Module_vcl.mk1
-rw-r--r--vcl/workben/xlsxfuzzer.cxx33
3 files changed, 83 insertions, 0 deletions
diff --git a/vcl/Executable_xlsxfuzzer.mk b/vcl/Executable_xlsxfuzzer.mk
new file mode 100644
index 000000000000..5040033a5daa
--- /dev/null
+++ b/vcl/Executable_xlsxfuzzer.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,xlsxfuzzer))
+
+$(eval $(call gb_Executable_use_api,xlsxfuzzer,\
+ offapi \
+ udkapi \
+))
+
+$(eval $(call gb_Executable_use_externals,xlsxfuzzer,\
+ $(fuzzer_externals) \
+))
+
+$(eval $(call gb_Executable_set_include,xlsxfuzzer,\
+ $$(INCLUDE) \
+ -I$(SRCDIR)/vcl/inc \
+))
+
+$(eval $(call gb_Executable_use_libraries,xlsxfuzzer,\
+ $(fuzzer_calc_libraries) \
+ $(fuzzer_core_libraries) \
+))
+
+$(eval $(call gb_Executable_use_static_libraries,xlsxfuzzer,\
+ findsofficepath \
+ ulingu \
+ fuzzer_calc \
+ fuzzerstubs \
+))
+
+$(eval $(call gb_Executable_add_exception_objects,xlsxfuzzer,\
+ vcl/workben/xlsxfuzzer \
+))
+
+$(eval $(call gb_Executable_add_libs,xlsxfuzzer,\
+ -lFuzzingEngine \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index d184d1a9765e..77a621f37a4e 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -157,6 +157,7 @@ $(eval $(call gb_Module_add_targets,vcl,\
Executable_wksfuzzer \
Executable_diffuzzer \
Executable_docxfuzzer \
+ Executable_xlsxfuzzer \
))
endif
diff --git a/vcl/workben/xlsxfuzzer.cxx b/vcl/workben/xlsxfuzzer.cxx
new file mode 100644
index 000000000000..ae4d74fed9cf
--- /dev/null
+++ b/vcl/workben/xlsxfuzzer.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 TestImportXLSX(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)TestImportXLSX(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: */