[Libreoffice-commits] online.git: kit/Kit.cpp wsd/LOOLWSD.cpp wsd/LOOLWSD.hpp

Jan Holesovsky kendy at collabora.com
Wed Feb 8 11:35:46 UTC 2017


 kit/Kit.cpp     |    8 +++++++-
 wsd/LOOLWSD.cpp |    8 +++++++-
 wsd/LOOLWSD.hpp |    1 +
 3 files changed, 15 insertions(+), 2 deletions(-)

New commits:
commit cd90d8adfe22f7e0368a16a9da42c0826ece0a49
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Feb 8 12:34:16 2017 +0100

    fuzzer: Add --dummy-lok command line option that bypases LibreOffice.
    
    When provided, the DummyLibreOfficeKit is used instead of the real one that
    calls LibreOffice.
    
    Change-Id: Ic170d7b4adb72ba17a2b066c509c2b1e657dbccf

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 21300d9..79e6f55 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -67,6 +67,7 @@
 
 #ifdef FUZZER
 #include <kit/DummyLibreOfficeKit.hpp>
+#include <wsd/LOOLWSD.hpp>
 #endif
 
 #define LIB_SOFFICEAPP  "lib" "sofficeapp" ".so"
@@ -1721,7 +1722,8 @@ void lokit_main(const std::string& childRoot,
 #else
             LibreOfficeKit* kit = nullptr;
 #ifdef FUZZER
-            kit = dummy_lok_init_2(instdir, userdir);
+            if (LOOLWSD::DummyLOK)
+                kit = dummy_lok_init_2(instdir, userdir);
 #endif
 #endif
             if (!kit)
@@ -1884,6 +1886,10 @@ void lokit_main(const std::string& childRoot,
 /// Initializes LibreOfficeKit for cross-fork re-use.
 bool globalPreinit(const std::string &loTemplate)
 {
+#ifdef FUZZER
+    if (LOOLWSD::DummyLOK)
+        return true;
+#endif
     const std::string libSofficeapp = loTemplate + "/program/" LIB_SOFFICEAPP;
     const std::string libMerged = loTemplate + "/program/" LIB_MERGED;
 
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 12f91c0..9411255 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1703,6 +1703,7 @@ std::atomic<int> LOOLWSD::ForKitProcId(-1);
 bool LOOLWSD::NoCapsForKit = false;
 #endif
 #ifdef FUZZER
+bool LOOLWSD::DummyLOK = false;
 std::string LOOLWSD::FuzzFileName = "";
 #endif
 std::string LOOLWSD::Cache = LOOLWSD_CACHEDIR;
@@ -2090,6 +2091,9 @@ void LOOLWSD::defineOptions(OptionSet& optionSet)
 #endif
 
 #ifdef FUZZER
+    optionSet.addOption(Option("dummy-lok", "", "Use empty (dummy) LibreOfficeKit implementation instead a real LibreOffice.")
+                        .required(false)
+                        .repeatable(false));
     optionSet.addOption(Option("fuzz", "", "Read input from the specified file for fuzzing.")
                         .required(false)
                         .repeatable(false)
@@ -2142,7 +2146,9 @@ void LOOLWSD::handleOption(const std::string& optionName,
 #endif
 
 #ifdef FUZZER
-    if (optionName == "fuzz")
+    if (optionName == "dummy-lok")
+        DummyLOK = true;
+    else if (optionName == "fuzz")
         FuzzFileName = value;
 #endif
 }
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index 7438c80..5126bb1 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -38,6 +38,7 @@ public:
     static bool NoCapsForKit;
     static std::atomic<int> ForKitWritePipe;
     static std::atomic<int> ForKitProcId;
+    static bool DummyLOK;
     static std::string FuzzFileName;
     static std::string Cache;
     static std::string ConfigFile;


More information about the Libreoffice-commits mailing list