[Libreoffice-commits] core.git: desktop/inc desktop/source vcl/workben

Caolán McNamara caolanm at redhat.com
Sun Oct 22 19:18:37 UTC 2017


 desktop/inc/app.hxx        |    5 
 desktop/source/app/app.cxx |   19 
 vcl/workben/fftester.cxx   |  867 +++++++++++++++++++++------------------------
 3 files changed, 417 insertions(+), 474 deletions(-)

New commits:
commit aa3c2526893cbf08a08f881b9e4b24dbd2b8b0b7
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Oct 22 17:29:21 2017 +0100

    oss-fuzz: drop our own afl related hackery
    
    Change-Id: Ia6a498c07fffd1790ad433287ef4d1cf82085887
    Reviewed-on: https://gerrit.libreoffice.org/43695
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx
index 50e3a0fa3811..0e5f8774d3c3 100644
--- a/desktop/inc/app.hxx
+++ b/desktop/inc/app.hxx
@@ -155,11 +155,6 @@ class Desktop : public Application
         */
         void                    CheckFirstRun( );
 
-        /** for ui-testing provide a mechanism to pseudo-restart by closing the
-            open frames and reopen the frame that appeared post initial startup
-        */
-        static void             DoExecute();
-
         static void             ShowBackingComponent(Desktop * progress);
 
         // on-demand acceptors
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index cae1d3ce8b22..56850c64e29b 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -1255,23 +1255,6 @@ struct ExecuteGlobals
 
 static ExecuteGlobals* pExecGlobals = nullptr;
 
-
-//This just calls Execute() for all normal uses of LibreOffice, but for
-//ui-testing if built with afl-clang-fast++ then on exit it will pseudo-restart
-//(up to 100 times)
-void Desktop::DoExecute()
-{
-#if !defined(__AFL_HAVE_MANUAL_CONTROL)
-    Execute();
-#else
-    while (__AFL_LOOP(1000))
-    {
-        Execute();
-        OpenDefault();
-    }
-#endif
-}
-
 int Desktop::Main()
 {
     pExecGlobals = new ExecuteGlobals();
@@ -1663,7 +1646,7 @@ int Desktop::Main()
                 // if this run of the office is triggered by restart, some additional actions should be done
                 DoRestartActionsIfNecessary( !rCmdLineArgs.IsInvisible() && !rCmdLineArgs.IsNoQuickstart() );
 
-                DoExecute();
+                Execute();
             }
         }
         catch(const css::document::CorruptedFilterConfigurationException& exFilterCfg)
diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx
index a39e3ddc9f2e..18c84d52fb27 100644
--- a/vcl/workben/fftester.cxx
+++ b/vcl/workben/fftester.cxx
@@ -18,18 +18,9 @@
  */
 
  /* e.g.
-        export CC=afl-clang-fast
-        export CXX=afl-clang-fast++
         make
         cp workdir/LinkTarget/Executable/fftester instdir/program
-        LD_LIBRARY_PATH=`pwd`/instdir/program AFL_PERSISTENT=1 afl-fuzz -t 50 -i ~/fuzz/in.png -o ~/fuzz/out.png -d -T png -m 50000000 instdir/program/fftester @@ png
-
-        On slower file formats like .doc you can probably drop the -t and rely on the
-        estimations, on faster file formats ironically not specifying a timeout will
-        result in a hilarious dramatic falloff in performance from thousands per second
-        to teens per second as tiny variations from the initial calculated
-        timeout will trigger a shutdown of the fftester and a restart and the
-        startup time is woeful (hence the AFL_PERSISTENT mode in the first place)
+        LD_LIBRARY_PATH=`pwd`/instdir/program instdir/program/fftester <foo> png
   */
 
 #include <sal/main.h>
@@ -50,8 +41,6 @@
 #include <vcl/wrkwin.hxx>
 #include <vcl/fltcall.hxx>
 #include <osl/file.hxx>
-#include <unistd.h>
-#include <signal.h>
 
 #include <../source/filter/igif/gifread.hxx>
 #include <../source/filter/ixbm/xbmread.hxx>
@@ -69,13 +58,6 @@ extern "C" { static void SAL_CALL thisModule() {} }
 typedef bool (*WFilterCall)(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
- * hiccups. */
-
-#define PERSIST_MAX 1000
-static unsigned int persist_cnt;
-
 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
 {
     int ret = -1;
@@ -109,481 +91,464 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
         utl::ConfigManager::EnableAvoidConfig();
         InitVCL();
 
-try_again:
-
+        if (strcmp(argv[2], "wmf") == 0 || strcmp(argv[2], "emf") == 0)
         {
-            if (strcmp(argv[2], "wmf") == 0 || strcmp(argv[2], "emf") == 0)
-            {
-                GDIMetaFile aGDIMetaFile;
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) ReadWindowMetafile(aFileStream, aGDIMetaFile);
-            }
-            else if (strcmp(argv[2], "jpg") == 0)
-            {
-                Graphic aGraphic;
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) ImportJPEG(aFileStream, aGraphic, GraphicFilterImportFlags::NONE, nullptr);
-            }
-            else if (strcmp(argv[2], "gif") == 0)
-            {
-                SvFileStream aFileStream(out, StreamMode::READ);
-                Graphic aGraphic;
-                ret = (int) ImportGIF(aFileStream, aGraphic);
-            }
-            else if (strcmp(argv[2], "xbm") == 0)
-            {
-                Graphic aGraphic;
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) ImportXBM(aFileStream, aGraphic);
-            }
-            else if (strcmp(argv[2], "xpm") == 0)
-            {
-                Graphic aGraphic;
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) ImportXPM(aFileStream, aGraphic);
-            }
-            else if (strcmp(argv[2], "png") == 0)
-            {
-                SvFileStream aFileStream(out, StreamMode::READ);
-                vcl::PNGReader aReader(aFileStream);
-            }
-            else if (strcmp(argv[2], "bmp") == 0)
-            {
-                Bitmap aTarget;
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) ReadDIB(aTarget, aFileStream, true);
-            }
-            else if (strcmp(argv[2], "svm") == 0)
-            {
-                GDIMetaFile aGDIMetaFile;
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ReadGDIMetaFile(aFileStream, aGDIMetaFile);
-            }
+            GDIMetaFile aGDIMetaFile;
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) ReadWindowMetafile(aFileStream, aGDIMetaFile);
+        }
+        else if (strcmp(argv[2], "jpg") == 0)
+        {
+            Graphic aGraphic;
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) ImportJPEG(aFileStream, aGraphic, GraphicFilterImportFlags::NONE, nullptr);
+        }
+        else if (strcmp(argv[2], "gif") == 0)
+        {
+            SvFileStream aFileStream(out, StreamMode::READ);
+            Graphic aGraphic;
+            ret = (int) ImportGIF(aFileStream, aGraphic);
+        }
+        else if (strcmp(argv[2], "xbm") == 0)
+        {
+            Graphic aGraphic;
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) ImportXBM(aFileStream, aGraphic);
+        }
+        else if (strcmp(argv[2], "xpm") == 0)
+        {
+            Graphic aGraphic;
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) ImportXPM(aFileStream, aGraphic);
+        }
+        else if (strcmp(argv[2], "png") == 0)
+        {
+            SvFileStream aFileStream(out, StreamMode::READ);
+            vcl::PNGReader aReader(aFileStream);
+        }
+        else if (strcmp(argv[2], "bmp") == 0)
+        {
+            Bitmap aTarget;
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) ReadDIB(aTarget, aFileStream, true);
+        }
+        else if (strcmp(argv[2], "svm") == 0)
+        {
+            GDIMetaFile aGDIMetaFile;
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ReadGDIMetaFile(aFileStream, aGDIMetaFile);
+        }
 #ifndef DISABLE_DYNLOADING
-            else if (strcmp(argv[2], "pcd") == 0)
-            {
-                static PFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libgielo.so");
-                    pfnImport = reinterpret_cast<PFilterCall>(
-                        aLibrary.getFunctionSymbol("icdGraphicImport"));
-                    aLibrary.release();
-                }
-                Graphic aGraphic;
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
-            }
-            else if (strcmp(argv[2], "dxf") == 0)
-            {
-                static PFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libgielo.so");
-                    pfnImport = reinterpret_cast<PFilterCall>(
-                        aLibrary.getFunctionSymbol("idxGraphicImport"));
-                    aLibrary.release();
-                }
-                Graphic aGraphic;
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
-            }
-            else if (strcmp(argv[2], "met") == 0)
-            {
-                static PFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libgielo.so");
-                    pfnImport = reinterpret_cast<PFilterCall>(
-                        aLibrary.getFunctionSymbol("imeGraphicImport"));
-                    aLibrary.release();
-                }
-                Graphic aGraphic;
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
-            }
-            else if ((strcmp(argv[2], "pbm") == 0) || strcmp(argv[2], "ppm") == 0)
-            {
-                static PFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libgielo.so");
-                    pfnImport = reinterpret_cast<PFilterCall>(
-                        aLibrary.getFunctionSymbol("ipbGraphicImport"));
-                    aLibrary.release();
-                }
-                Graphic aGraphic;
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
-            }
-            else if (strcmp(argv[2], "psd") == 0)
-            {
-                static PFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libgielo.so");
-                    pfnImport = reinterpret_cast<PFilterCall>(
-                        aLibrary.getFunctionSymbol("ipdGraphicImport"));
-                    aLibrary.release();
-                }
-                Graphic aGraphic;
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
-            }
-            else if (strcmp(argv[2], "eps") == 0)
-            {
-                static PFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libgielo.so");
-                    pfnImport = reinterpret_cast<PFilterCall>(
-                        aLibrary.getFunctionSymbol("ipsGraphicImport"));
-                    aLibrary.release();
-                }
-                Graphic aGraphic;
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
-            }
-            else if (strcmp(argv[2], "pct") == 0)
-            {
-                static PFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libgielo.so");
-                    pfnImport = reinterpret_cast<PFilterCall>(
-                        aLibrary.getFunctionSymbol("iptGraphicImport"));
-                    aLibrary.release();
-                }
-                Graphic aGraphic;
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
-            }
-            else if (strcmp(argv[2], "pcx") == 0)
-            {
-                static PFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libgielo.so");
-                    pfnImport = reinterpret_cast<PFilterCall>(
-                        aLibrary.getFunctionSymbol("ipxGraphicImport"));
-                    aLibrary.release();
-                }
-                Graphic aGraphic;
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
-            }
-            else if (strcmp(argv[2], "ras") == 0)
-            {
-                static PFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libgielo.so");
-                    pfnImport = reinterpret_cast<PFilterCall>(
-                        aLibrary.getFunctionSymbol("iraGraphicImport"));
-                    aLibrary.release();
-                }
-                Graphic aGraphic;
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
-            }
-            else if (strcmp(argv[2], "tga") == 0)
-            {
-                static PFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libgielo.so");
-                    pfnImport = reinterpret_cast<PFilterCall>(
-                        aLibrary.getFunctionSymbol("itgGraphicImport"));
-                    aLibrary.release();
-                }
-                Graphic aGraphic;
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
-            }
-            else if (strcmp(argv[2], "tif") == 0)
-            {
-                static PFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libgielo.so");
-                    pfnImport = reinterpret_cast<PFilterCall>(
-                        aLibrary.getFunctionSymbol("itiGraphicImport"));
-                    aLibrary.release();
-                }
-                Graphic aGraphic;
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
-            }
-            else if ((strcmp(argv[2], "doc") == 0) || (strcmp(argv[2], "ww8") == 0))
-            {
-                static FFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libmswordlo.so", SAL_LOADMODULE_LAZY);
-                    pfnImport = reinterpret_cast<FFilterCall>(
-                        aLibrary.getFunctionSymbol("TestImportWW8"));
-                    aLibrary.release();
-                }
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream);
-            }
-            else if (strcmp(argv[2], "ww6") == 0)
+        else if (strcmp(argv[2], "pcd") == 0)
+        {
+            static PFilterCall pfnImport(nullptr);
+            if (!pfnImport)
+            {
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libgielo.so");
+                pfnImport = reinterpret_cast<PFilterCall>(
+                    aLibrary.getFunctionSymbol("icdGraphicImport"));
+                aLibrary.release();
+            }
+            Graphic aGraphic;
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
+        }
+        else if (strcmp(argv[2], "dxf") == 0)
+        {
+            static PFilterCall pfnImport(nullptr);
+            if (!pfnImport)
+            {
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libgielo.so");
+                pfnImport = reinterpret_cast<PFilterCall>(
+                    aLibrary.getFunctionSymbol("idxGraphicImport"));
+                aLibrary.release();
+            }
+            Graphic aGraphic;
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
+        }
+        else if (strcmp(argv[2], "met") == 0)
+        {
+            static PFilterCall pfnImport(nullptr);
+            if (!pfnImport)
+            {
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libgielo.so");
+                pfnImport = reinterpret_cast<PFilterCall>(
+                    aLibrary.getFunctionSymbol("imeGraphicImport"));
+                aLibrary.release();
+            }
+            Graphic aGraphic;
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
+        }
+        else if ((strcmp(argv[2], "pbm") == 0) || strcmp(argv[2], "ppm") == 0)
+        {
+            static PFilterCall pfnImport(nullptr);
+            if (!pfnImport)
+            {
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libgielo.so");
+                pfnImport = reinterpret_cast<PFilterCall>(
+                    aLibrary.getFunctionSymbol("ipbGraphicImport"));
+                aLibrary.release();
+            }
+            Graphic aGraphic;
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
+        }
+        else if (strcmp(argv[2], "psd") == 0)
+        {
+            static PFilterCall pfnImport(nullptr);
+            if (!pfnImport)
+            {
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libgielo.so");
+                pfnImport = reinterpret_cast<PFilterCall>(
+                    aLibrary.getFunctionSymbol("ipdGraphicImport"));
+                aLibrary.release();
+            }
+            Graphic aGraphic;
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
+        }
+        else if (strcmp(argv[2], "eps") == 0)
+        {
+            static PFilterCall pfnImport(nullptr);
+            if (!pfnImport)
+            {
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libgielo.so");
+                pfnImport = reinterpret_cast<PFilterCall>(
+                    aLibrary.getFunctionSymbol("ipsGraphicImport"));
+                aLibrary.release();
+            }
+            Graphic aGraphic;
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
+        }
+        else if (strcmp(argv[2], "pct") == 0)
+        {
+            static PFilterCall pfnImport(nullptr);
+            if (!pfnImport)
+            {
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libgielo.so");
+                pfnImport = reinterpret_cast<PFilterCall>(
+                    aLibrary.getFunctionSymbol("iptGraphicImport"));
+                aLibrary.release();
+            }
+            Graphic aGraphic;
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
+        }
+        else if (strcmp(argv[2], "pcx") == 0)
+        {
+            static PFilterCall pfnImport(nullptr);
+            if (!pfnImport)
+            {
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libgielo.so");
+                pfnImport = reinterpret_cast<PFilterCall>(
+                    aLibrary.getFunctionSymbol("ipxGraphicImport"));
+                aLibrary.release();
+            }
+            Graphic aGraphic;
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
+        }
+        else if (strcmp(argv[2], "ras") == 0)
+        {
+            static PFilterCall pfnImport(nullptr);
+            if (!pfnImport)
+            {
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libgielo.so");
+                pfnImport = reinterpret_cast<PFilterCall>(
+                    aLibrary.getFunctionSymbol("iraGraphicImport"));
+                aLibrary.release();
+            }
+            Graphic aGraphic;
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
+        }
+        else if (strcmp(argv[2], "tga") == 0)
+        {
+            static PFilterCall pfnImport(nullptr);
+            if (!pfnImport)
+            {
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libgielo.so");
+                pfnImport = reinterpret_cast<PFilterCall>(
+                    aLibrary.getFunctionSymbol("itgGraphicImport"));
+                aLibrary.release();
+            }
+            Graphic aGraphic;
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
+        }
+        else if (strcmp(argv[2], "tif") == 0)
+        {
+            static PFilterCall pfnImport(nullptr);
+            if (!pfnImport)
+            {
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libgielo.so");
+                pfnImport = reinterpret_cast<PFilterCall>(
+                    aLibrary.getFunctionSymbol("itiGraphicImport"));
+                aLibrary.release();
+            }
+            Graphic aGraphic;
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr);
+        }
+        else if ((strcmp(argv[2], "doc") == 0) || (strcmp(argv[2], "ww8") == 0))
+        {
+            static FFilterCall pfnImport(nullptr);
+            if (!pfnImport)
             {
-                static FFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libmswordlo.so", SAL_LOADMODULE_LAZY);
-                    pfnImport = reinterpret_cast<FFilterCall>(
-                        aLibrary.getFunctionSymbol("TestImportWW6"));
-                    aLibrary.release();
-                }
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream);
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libmswordlo.so", SAL_LOADMODULE_LAZY);
+                pfnImport = reinterpret_cast<FFilterCall>(
+                    aLibrary.getFunctionSymbol("TestImportWW8"));
+                aLibrary.release();
             }
-            else if (strcmp(argv[2], "ww2") == 0)
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream);
+        }
+        else if (strcmp(argv[2], "ww6") == 0)
+        {
+            static FFilterCall pfnImport(nullptr);
+            if (!pfnImport)
             {
-                static FFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libmswordlo.so", SAL_LOADMODULE_LAZY);
-                    pfnImport = reinterpret_cast<FFilterCall>(
-                        aLibrary.getFunctionSymbol("TestImportWW2"));
-                    aLibrary.release();
-                }
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream);
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libmswordlo.so", SAL_LOADMODULE_LAZY);
+                pfnImport = reinterpret_cast<FFilterCall>(
+                    aLibrary.getFunctionSymbol("TestImportWW6"));
+                aLibrary.release();
             }
-            else if (strcmp(argv[2], "rtf") == 0)
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream);
+        }
+        else if (strcmp(argv[2], "ww2") == 0)
+        {
+            static FFilterCall pfnImport(nullptr);
+            if (!pfnImport)
             {
-                static FFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libmswordlo.so", SAL_LOADMODULE_LAZY);
-                    pfnImport = reinterpret_cast<FFilterCall>(
-                        aLibrary.getFunctionSymbol("TestImportRTF"));
-                    aLibrary.release();
-                }
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream);
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libmswordlo.so", SAL_LOADMODULE_LAZY);
+                pfnImport = reinterpret_cast<FFilterCall>(
+                    aLibrary.getFunctionSymbol("TestImportWW2"));
+                aLibrary.release();
             }
-            else if (strcmp(argv[2], "fodt") == 0)
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream);
+        }
+        else if (strcmp(argv[2], "rtf") == 0)
+        {
+            static FFilterCall pfnImport(nullptr);
+            if (!pfnImport)
             {
-                static FFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libswlo.so", SAL_LOADMODULE_LAZY);
-                    pfnImport = reinterpret_cast<FFilterCall>(
-                        aLibrary.getFunctionSymbol("TestImportFODT"));
-                    aLibrary.release();
-                }
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream);
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libmswordlo.so", SAL_LOADMODULE_LAZY);
+                pfnImport = reinterpret_cast<FFilterCall>(
+                    aLibrary.getFunctionSymbol("TestImportRTF"));
+                aLibrary.release();
             }
-            else if (strcmp(argv[2], "fods") == 0)
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream);
+        }
+        else if (strcmp(argv[2], "fodt") == 0)
+        {
+            static FFilterCall pfnImport(nullptr);
+            if (!pfnImport)
             {
-                static FFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libsclo.so", SAL_LOADMODULE_LAZY);
-                    pfnImport = reinterpret_cast<FFilterCall>(
-                        aLibrary.getFunctionSymbol("TestImportFODS"));
-                    aLibrary.release();
-                }
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream);
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libswlo.so", SAL_LOADMODULE_LAZY);
+                pfnImport = reinterpret_cast<FFilterCall>(
+                    aLibrary.getFunctionSymbol("TestImportFODT"));
+                aLibrary.release();
             }
-            else if (strcmp(argv[2], "fodp") == 0)
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream);
+        }
+        else if (strcmp(argv[2], "fods") == 0)
+        {
+            static FFilterCall pfnImport(nullptr);
+            if (!pfnImport)
             {
-                static FFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libsdlo.so", SAL_LOADMODULE_LAZY);
-                    pfnImport = reinterpret_cast<FFilterCall>(
-                        aLibrary.getFunctionSymbol("TestImportFODP"));
-                    aLibrary.release();
-                }
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream);
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libsclo.so", SAL_LOADMODULE_LAZY);
+                pfnImport = reinterpret_cast<FFilterCall>(
+                    aLibrary.getFunctionSymbol("TestImportFODS"));
+                aLibrary.release();
             }
-            else if (strcmp(argv[2], "xls") == 0)
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream);
+        }
+        else if (strcmp(argv[2], "fodp") == 0)
+        {
+            static FFilterCall pfnImport(nullptr);
+            if (!pfnImport)
             {
-                static WFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libscfiltlo.so", SAL_LOADMODULE_LAZY);
-                    pfnImport = reinterpret_cast<WFilterCall>(
-                        aLibrary.getFunctionSymbol("TestImportXLS"));
-                    aLibrary.release();
-                }
-                ret = (int) (*pfnImport)(out);
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libsdlo.so", SAL_LOADMODULE_LAZY);
+                pfnImport = reinterpret_cast<FFilterCall>(
+                    aLibrary.getFunctionSymbol("TestImportFODP"));
+                aLibrary.release();
             }
-            else if (strcmp(argv[2], "hwp") == 0)
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream);
+        }
+        else if (strcmp(argv[2], "xls") == 0)
+        {
+            static WFilterCall pfnImport(nullptr);
+            if (!pfnImport)
             {
-                static FFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libhwplo.so", SAL_LOADMODULE_LAZY);
-                    pfnImport = reinterpret_cast<FFilterCall>(
-                        aLibrary.getFunctionSymbol("TestImportHWP"));
-                    aLibrary.release();
-                }
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream);
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libscfiltlo.so", SAL_LOADMODULE_LAZY);
+                pfnImport = reinterpret_cast<WFilterCall>(
+                    aLibrary.getFunctionSymbol("TestImportXLS"));
+                aLibrary.release();
             }
-            else if (strcmp(argv[2], "602") == 0)
+            ret = (int) (*pfnImport)(out);
+        }
+        else if (strcmp(argv[2], "hwp") == 0)
+        {
+            static FFilterCall pfnImport(nullptr);
+            if (!pfnImport)
             {
-                static FFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libt602filterlo.so", SAL_LOADMODULE_LAZY);
-                    pfnImport = reinterpret_cast<FFilterCall>(
-                        aLibrary.getFunctionSymbol("TestImport602"));
-                    aLibrary.release();
-                }
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream);
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libhwplo.so", SAL_LOADMODULE_LAZY);
+                pfnImport = reinterpret_cast<FFilterCall>(
+                    aLibrary.getFunctionSymbol("TestImportHWP"));
+                aLibrary.release();
             }
-            else if (strcmp(argv[2], "lwp") == 0)
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream);
+        }
+        else if (strcmp(argv[2], "602") == 0)
+        {
+            static FFilterCall pfnImport(nullptr);
+            if (!pfnImport)
             {
-                static FFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "liblwpftlo.so", SAL_LOADMODULE_LAZY);
-                    pfnImport = reinterpret_cast<FFilterCall>(
-                        aLibrary.getFunctionSymbol("TestImportLWP"));
-                    aLibrary.release();
-                }
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream);
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libt602filterlo.so", SAL_LOADMODULE_LAZY);
+                pfnImport = reinterpret_cast<FFilterCall>(
+                    aLibrary.getFunctionSymbol("TestImport602"));
+                aLibrary.release();
             }
-            else if (strcmp(argv[2], "ppt") == 0)
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream);
+        }
+        else if (strcmp(argv[2], "lwp") == 0)
+        {
+            static FFilterCall pfnImport(nullptr);
+            if (!pfnImport)
             {
-                static FFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libsdfiltlo.so", SAL_LOADMODULE_LAZY);
-                    pfnImport = reinterpret_cast<FFilterCall>(
-                        aLibrary.getFunctionSymbol("TestImportPPT"));
-                    aLibrary.release();
-                }
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream);
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "liblwpftlo.so", SAL_LOADMODULE_LAZY);
+                pfnImport = reinterpret_cast<FFilterCall>(
+                    aLibrary.getFunctionSymbol("TestImportLWP"));
+                aLibrary.release();
             }
-            else if (strcmp(argv[2], "cgm") == 0)
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream);
+        }
+        else if (strcmp(argv[2], "ppt") == 0)
+        {
+            static FFilterCall pfnImport(nullptr);
+            if (!pfnImport)
             {
-                static FFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libsdlo.so", SAL_LOADMODULE_LAZY);
-                    pfnImport = reinterpret_cast<FFilterCall>(
-                        aLibrary.getFunctionSymbol("TestImportCGM"));
-                    aLibrary.release();
-                }
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream);
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libsdfiltlo.so", SAL_LOADMODULE_LAZY);
+                pfnImport = reinterpret_cast<FFilterCall>(
+                    aLibrary.getFunctionSymbol("TestImportPPT"));
+                aLibrary.release();
             }
-            else if (strcmp(argv[2], "qpw") == 0)
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream);
+        }
+        else if (strcmp(argv[2], "cgm") == 0)
+        {
+            static FFilterCall pfnImport(nullptr);
+            if (!pfnImport)
             {
-                static FFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libscfiltlo.so", SAL_LOADMODULE_LAZY);
-                    pfnImport = reinterpret_cast<FFilterCall>(
-                        aLibrary.getFunctionSymbol("TestImportQPW"));
-                    aLibrary.release();
-                }
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream);
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libsdlo.so", SAL_LOADMODULE_LAZY);
+                pfnImport = reinterpret_cast<FFilterCall>(
+                    aLibrary.getFunctionSymbol("TestImportCGM"));
+                aLibrary.release();
             }
-            else if (strcmp(argv[2], "sc-rtf") == 0)
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream);
+        }
+        else if (strcmp(argv[2], "qpw") == 0)
+        {
+            static FFilterCall pfnImport(nullptr);
+            if (!pfnImport)
             {
-                static FFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libscfiltlo.so", SAL_LOADMODULE_LAZY);
-                    pfnImport = reinterpret_cast<FFilterCall>(
-                        aLibrary.getFunctionSymbol("TestImportCalcRTF"));
-                    aLibrary.release();
-                }
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream);
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libscfiltlo.so", SAL_LOADMODULE_LAZY);
+                pfnImport = reinterpret_cast<FFilterCall>(
+                    aLibrary.getFunctionSymbol("TestImportQPW"));
+                aLibrary.release();
             }
-            else if (strcmp(argv[2], "slk") == 0)
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream);
+        }
+        else if (strcmp(argv[2], "sc-rtf") == 0)
+        {
+            static FFilterCall pfnImport(nullptr);
+            if (!pfnImport)
             {
-                static FFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libsclo.so", SAL_LOADMODULE_LAZY);
-                    pfnImport = reinterpret_cast<FFilterCall>(
-                        aLibrary.getFunctionSymbol("TestImportSLK"));
-                    aLibrary.release();
-                }
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream);
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libscfiltlo.so", SAL_LOADMODULE_LAZY);
+                pfnImport = reinterpret_cast<FFilterCall>(
+                    aLibrary.getFunctionSymbol("TestImportCalcRTF"));
+                aLibrary.release();
             }
-            else if (strcmp(argv[2], "ole") == 0)
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream);
+        }
+        else if (strcmp(argv[2], "slk") == 0)
+        {
+            static FFilterCall pfnImport(nullptr);
+            if (!pfnImport)
             {
-                static FFilterCall pfnImport(nullptr);
-                if (!pfnImport)
-                {
-                    osl::Module aLibrary;
-                    aLibrary.loadRelative(&thisModule, "libsotlo.so", SAL_LOADMODULE_LAZY);
-                    pfnImport = reinterpret_cast<FFilterCall>(
-                        aLibrary.getFunctionSymbol("TestImportOLE2"));
-                    aLibrary.release();
-                }
-                SvFileStream aFileStream(out, StreamMode::READ);
-                ret = (int) (*pfnImport)(aFileStream);
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libsclo.so", SAL_LOADMODULE_LAZY);
+                pfnImport = reinterpret_cast<FFilterCall>(
+                    aLibrary.getFunctionSymbol("TestImportSLK"));
+                aLibrary.release();
             }
-#endif
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream);
         }
-
-        /* To signal successful completion of a run, we need to deliver
-           SIGSTOP to our own process, then loop to the very beginning
-           once we're resumed by the supervisor process. We do this only
-           if AFL_PERSISTENT is set to retain normal behavior when the
-           program is executed directly; and take note of PERSIST_MAX. */
-        if (getenv("AFL_PERSISTENT") && persist_cnt++ < PERSIST_MAX)
+        else if (strcmp(argv[2], "ole") == 0)
         {
-            raise(SIGSTOP);
-            goto try_again;
+            static FFilterCall pfnImport(nullptr);
+            if (!pfnImport)
+            {
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libsotlo.so", SAL_LOADMODULE_LAZY);
+                pfnImport = reinterpret_cast<FFilterCall>(
+                    aLibrary.getFunctionSymbol("TestImportOLE2"));
+                aLibrary.release();
+            }
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream);
         }
-
-        /* If AFL_PERSISTENT not set or PERSIST_MAX exceeded, exit normally. */
+#endif
     }
     catch (...)
     {
         abort();
     }
 
-    _exit(ret);
+    return ret;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list