[Libreoffice-commits] core.git: 6 commits - Makefile.in Repository.mk vcl/Executable_epsfuzzer.mk vcl/inc vcl/Module_vcl.mk vcl/source vcl/workben

Caolán McNamara caolanm at redhat.com
Fri Jan 27 20:49:43 UTC 2017


 Makefile.in                 |    2 -
 Repository.mk               |    1 
 vcl/Executable_epsfuzzer.mk |   47 ++++++++++++++++++++++++++++++
 vcl/Module_vcl.mk           |    1 
 vcl/inc/impgraph.hxx        |    2 +
 vcl/source/gdi/impgraph.cxx |   68 ++++++++++++++++++++++++++++++++++++--------
 vcl/workben/epsfuzzer.cxx   |   24 +++++++++++++++
 7 files changed, 133 insertions(+), 12 deletions(-)

New commits:
commit 3084e8f5b12e865d565278168c27c7af15282191
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jan 26 12:23:10 2017 +0000

    add eps fuzzer
    
    Change-Id: I7455a01076fc7c5fd16bbb90914ac93c236b2a3b

diff --git a/Makefile.in b/Makefile.in
index c56b798..5f7b215 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -426,7 +426,7 @@ $(foreach ide,\
     eclipsecdt,\
 $(eval $(call gb_Top_GbuildToIdeIntegration,$(ide))))
 
-fuzzers: Library_sal Library_salhelper Library_reg Library_store Library_unoidl codemaker Library_cppu Library_i18nlangtag Library_cppuhelper Library_comphelper StaticLibrary_ulingu StaticLibrary_jpeg StaticLibrary_findsofficepath Library_tl Rdb_services udkapi offapi Library_clew Library_gie Library_reflection Library_invocadapt Library_bootstrap Library_introspection Library_stocservices Library_xmlreader Library_gcc3_uno instsetoo_native more_fonts StaticLibrary_fuzzer Executable_wmffuzzer Executable_jpgfuzzer Executable_giffuzzer Executable_xbmfuzzer Executable_xpmfuzzer Executable_pngfuzzer Executable_bmpfuzzer Executable_svmfuzzer Executable_pcdfuzzer Executable_dxffuzzer Executable_metfuzzer Executable_ppmfuzzer Executable_psdfuzzer
+fuzzers: Library_sal Library_salhelper Library_reg Library_store Library_unoidl codemaker Library_cppu Library_i18nlangtag Library_cppuhelper Library_comphelper StaticLibrary_ulingu StaticLibrary_jpeg StaticLibrary_findsofficepath Library_tl Rdb_services udkapi offapi Library_clew Library_gie Library_reflection Library_invocadapt Library_bootstrap Library_introspection Library_stocservices Library_xmlreader Library_gcc3_uno instsetoo_native more_fonts StaticLibrary_fuzzer Executable_wmffuzzer Executable_jpgfuzzer Executable_giffuzzer Executable_xbmfuzzer Executable_xpmfuzzer Executable_pngfuzzer Executable_bmpfuzzer Executable_svmfuzzer Executable_pcdfuzzer Executable_dxffuzzer Executable_metfuzzer Executable_ppmfuzzer Executable_psdfuzzer Executable_epsfuzzer
 
 endif # MAKE_RESTARTS
 
diff --git a/Repository.mk b/Repository.mk
index e039a8c..d196c5c 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -106,6 +106,7 @@ $(eval $(call gb_Helper_register_executables_for_install,OOO,brand, \
 	$(call gb_Helper_optional,FUZZERS,metfuzzer) \
 	$(call gb_Helper_optional,FUZZERS,ppmfuzzer) \
 	$(call gb_Helper_optional,FUZZERS,psdfuzzer) \
+	$(call gb_Helper_optional,FUZZERS,epsfuzzer) \
 	$(if $(filter-out ANDROID IOS MACOSX WNT,$(OS)),oosplash) \
 	soffice_bin \
 	$(if $(filter DESKTOP,$(BUILD_TYPE)),unopkg_bin) \
diff --git a/vcl/Executable_epsfuzzer.mk b/vcl/Executable_epsfuzzer.mk
new file mode 100644
index 0000000..445bfc4
--- /dev/null
+++ b/vcl/Executable_epsfuzzer.mk
@@ -0,0 +1,47 @@
+# -*- 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,epsfuzzer))
+
+$(eval $(call gb_Executable_use_api,epsfuzzer,\
+    offapi \
+    udkapi \
+))
+
+$(eval $(call gb_Executable_use_externals,epsfuzzer,\
+	$(fuzzer_externals) \
+))
+
+$(eval $(call gb_Executable_set_include,epsfuzzer,\
+    $$(INCLUDE) \
+    -I$(SRCDIR)/vcl/inc \
+))
+
+$(eval $(call gb_Executable_use_libraries,epsfuzzer,\
+	$(fuzzer_libraries) \
+))
+
+$(eval $(call gb_Executable_use_static_libraries,epsfuzzer,\
+    findsofficepath \
+    ulingu \
+    fuzzer \
+))
+
+$(eval $(call gb_Executable_add_exception_objects,epsfuzzer,\
+	vcl/workben/epsfuzzer \
+))
+
+$(eval $(call gb_Executable_add_libs,epsfuzzer,\
+	-lFuzzingEngine \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index a10236b..cd6c5ab 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -119,6 +119,7 @@ $(eval $(call gb_Module_add_targets,vcl,\
     Executable_metfuzzer \
     Executable_ppmfuzzer \
     Executable_psdfuzzer \
+    Executable_epsfuzzer \
 ))
 endif
 
diff --git a/vcl/workben/epsfuzzer.cxx b/vcl/workben/epsfuzzer.cxx
new file mode 100644
index 0000000..9b03729
--- /dev/null
+++ b/vcl/workben/epsfuzzer.cxx
@@ -0,0 +1,24 @@
+/* -*- 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 ipsGraphicImport(SvStream& rStream, Graphic& rGraphic, FilterConfigItem* pConfigItem);
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+    SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+    Graphic aGraphic;
+    (void)ipsGraphicImport(aStream, aGraphic, nullptr);
+    return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit f40aba6bf6ebe6a2b0da7d5e2fe53e470fe9e0f2
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jan 27 16:25:09 2017 +0000

    coverity#1371303 Missing move assignment operator
    
    Change-Id: I0dec3e192f3da895398a8b011c0e7275aab59d73

diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index 041caf1..574a907 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -55,6 +55,7 @@ private:
 
                         ImpGraphic();
                         ImpGraphic( const ImpGraphic& rImpGraphic );
+                        ImpGraphic( ImpGraphic&& rImpGraphic );
                         ImpGraphic( const Bitmap& rBmp );
                         ImpGraphic( const BitmapEx& rBmpEx );
                         ImpGraphic(const SvgDataPtr& rSvgDataPtr);
@@ -65,6 +66,7 @@ public:
 private:
 
     ImpGraphic&         operator=( const ImpGraphic& rImpGraphic );
+    ImpGraphic&         operator=( ImpGraphic&& rImpGraphic );
     bool                operator==( const ImpGraphic& rImpGraphic ) const;
     bool                operator!=( const ImpGraphic& rImpGraphic ) const { return !( *this == rImpGraphic ); }
 
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 0b03cee..51b58c6 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -128,6 +128,25 @@ ImpGraphic::ImpGraphic(const ImpGraphic& rImpGraphic)
     }
 }
 
+ImpGraphic::ImpGraphic(ImpGraphic&& rImpGraphic)
+    : maMetaFile(std::move(rImpGraphic.maMetaFile))
+    , maEx(std::move(rImpGraphic.maEx))
+    , maSwapInfo(std::move(rImpGraphic.maSwapInfo))
+    , mpAnimation(std::move(rImpGraphic.mpAnimation))
+    , mpContext(std::move(rImpGraphic.mpContext))
+    , mpSwapFile(std::move(rImpGraphic.mpSwapFile))
+    , mpGfxLink(std::move(rImpGraphic.mpGfxLink))
+    , meType(rImpGraphic.meType)
+    , mnSizeBytes(rImpGraphic.mnSizeBytes)
+    , mbSwapOut(rImpGraphic.mbSwapOut)
+    , mbDummyContext(rImpGraphic.mbDummyContext)
+    , maSvgData(std::move(rImpGraphic.maSvgData))
+    , maPdfData(std::move(rImpGraphic.maPdfData))
+{
+    rImpGraphic.ImplClear();
+    rImpGraphic.mbDummyContext = false;
+}
+
 ImpGraphic::ImpGraphic( const Bitmap& rBitmap ) :
         maEx            ( rBitmap ),
         meType          ( !rBitmap.IsEmpty() ? GraphicType::Bitmap : GraphicType::NONE ),
@@ -217,6 +236,28 @@ ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic )
     return *this;
 }
 
+ImpGraphic& ImpGraphic::operator=(ImpGraphic&& rImpGraphic)
+{
+    maMetaFile = std::move(rImpGraphic.maMetaFile);
+    meType = rImpGraphic.meType;
+    mnSizeBytes = rImpGraphic.mnSizeBytes;
+    maSwapInfo = std::move(rImpGraphic.maSwapInfo);
+    mpContext = std::move(rImpGraphic.mpContext);
+    mbDummyContext = rImpGraphic.mbDummyContext;
+    mpAnimation = std::move(rImpGraphic.mpAnimation);
+    maEx = std::move(rImpGraphic.maEx);
+    mbSwapOut = rImpGraphic.mbSwapOut;
+    mpSwapFile = std::move(rImpGraphic.mpSwapFile);
+    mpGfxLink = std::move(rImpGraphic.mpGfxLink);
+    maSvgData = std::move(rImpGraphic.maSvgData);
+    maPdfData = std::move(rImpGraphic.maPdfData);
+
+    rImpGraphic.ImplClear();
+    rImpGraphic.mbDummyContext = false;
+
+    return *this;
+}
+
 bool ImpGraphic::operator==( const ImpGraphic& rImpGraphic ) const
 {
     bool bRet = false;
commit 15a2a39ce621dc78449f28301beee895e67aa64f
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jan 27 16:12:44 2017 +0000

    everything ImplClear clears is managed by their dtors anyway
    
    Change-Id: Icafd4a4915d2fb3159b50409e5fc443c58d43d57

diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 7425678..0b03cee 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -176,7 +176,6 @@ ImpGraphic::ImpGraphic( const GDIMetaFile& rMtf ) :
 
 ImpGraphic::~ImpGraphic()
 {
-    ImplClear();
 }
 
 ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic )
commit 9aebc26c9b0aa85acdd8429d16c996f359de3062
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jan 27 16:12:04 2017 +0000

    Animation dtor will be called anyway, so drop Clear
    
    Change-Id: Ifa5a1cf6d782af0bb73ceff10f5a2a2daa4457d4

diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 575ad21..7425678 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -298,13 +298,7 @@ void ImpGraphic::ImplClearGraphics()
 {
     maEx.Clear();
     maMetaFile.Clear();
-
-    if( mpAnimation )
-    {
-        mpAnimation->Clear();
-        mpAnimation.reset();
-    }
-
+    mpAnimation.reset();
     mpGfxLink.reset();
     maSvgData.reset();
     maPdfData = uno::Sequence<sal_Int8>();
commit 00f0694c09241e7708e9443c34b3896be50dfda5
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jan 27 16:10:03 2017 +0000

    everything reset by ImplClear is going to be overwritten anyway
    
    Change-Id: I94de8723a43d177fdf2caf0d8d3e529200d2e718

diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index e9fcfa5..575ad21 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -183,8 +183,6 @@ ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic )
 {
     if( &rImpGraphic != this )
     {
-        ImplClear();
-
         maMetaFile = rImpGraphic.maMetaFile;
         meType = rImpGraphic.meType;
         mnSizeBytes = rImpGraphic.mnSizeBytes;
commit a42e8baed472933d706578916d00b672bb62dedc
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jan 27 15:55:09 2017 +0000

    we copy the flag for the context in the ctor, but not the context
    
    which is worrying, copy the other missing maSwapInfo too which should be safe
    to do.
    
    in the assignment operator, we don't copy any of those three fields at all, which
    is inconsistent
    
    save and restore the context and context flags on the piece where we overwrite
    ourself via *this = tempobj
    
    Change-Id: I06a7d491f95dcb113a3c705ceeb41f576ab0a514

diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index a82e67a..e9fcfa5 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -108,6 +108,8 @@ ImpGraphic::ImpGraphic() :
 ImpGraphic::ImpGraphic(const ImpGraphic& rImpGraphic)
     : maMetaFile(rImpGraphic.maMetaFile)
     , maEx(rImpGraphic.maEx)
+    , maSwapInfo(rImpGraphic.maSwapInfo)
+    , mpContext(rImpGraphic.mpContext)
     , mpSwapFile(rImpGraphic.mpSwapFile)
     , meType(rImpGraphic.meType)
     , mnSizeBytes(rImpGraphic.mnSizeBytes)
@@ -187,6 +189,10 @@ ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic )
         meType = rImpGraphic.meType;
         mnSizeBytes = rImpGraphic.mnSizeBytes;
 
+        maSwapInfo = rImpGraphic.maSwapInfo;
+        mpContext = rImpGraphic.mpContext;
+        mbDummyContext = rImpGraphic.mbDummyContext;
+
         mpAnimation.reset();
 
         if ( rImpGraphic.mpAnimation )
@@ -1256,10 +1262,18 @@ bool ImpGraphic::ImplSwapIn( SvStream* xIStm )
             std::shared_ptr<ImpSwapFile> xSwapFile(std::move(mpSwapFile));
             assert(!mpSwapFile);
 
+            std::shared_ptr<GraphicReader> xContext(std::move(mpContext));
+            assert(!mpContext);
+
+            bool bDummyContext = mbDummyContext;
+            mbDummyContext = false;
+
             bRet = ImplReadEmbedded( *xIStm );
 
-            //restore ownership of the swap file
+            //restore ownership of the swap file and context
             mpSwapFile = std::move(xSwapFile);
+            mpContext = std::move(xContext);
+            mbDummyContext = bDummyContext;
 
             if (!bRet)
             {


More information about the Libreoffice-commits mailing list