sw/source/filter/ww8/ww8graf2.cxx |   12 ++++++++++--
 sw/source/filter/ww8/ww8par.hxx   |    5 +++++
 2 files changed, 15 insertions(+), 2 deletions(-)

New commits:
commit 5547797c6596945ef104176b6094a152f746da10
Author: Caolán McNamara <caol...@redhat.com>
Date:   Tue Feb 13 10:02:38 2018 +0000

    ofz#2980 Timeout
    
    Change-Id: Id36e0e8ae11a145b5efa976c20261af931c1d58b
    Reviewed-on: https://gerrit.libreoffice.org/49627
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/source/filter/ww8/ww8graf2.cxx 
b/sw/source/filter/ww8/ww8graf2.cxx
index 8a4f11102fb6..a1dbe9fc17e8 100644
--- a/sw/source/filter/ww8/ww8graf2.cxx
+++ b/sw/source/filter/ww8/ww8graf2.cxx
@@ -29,6 +29,7 @@
 #include <sfx2/app.hxx>
 #include <sfx2/docfile.hxx>
 #include <sfx2/fcontnr.hxx>
+#include <unotools/configmgr.hxx>
 #include <grfatr.hxx>
 #include <fmtanchr.hxx>
 #include <fmtcntnt.hxx>
@@ -267,12 +268,19 @@ bool SwWW8ImplReader::ReadGrafFile(OUString& rFileName, 
Graphic*& rpGraphic,
     }
 
     GDIMetaFile aWMF;
-    pSt->Seek( nPosFc );
-    bool bOk = ReadWindowMetafile( *pSt, aWMF );
+    bool bOk = checkSeek(*pSt, nPosFc) && ReadWindowMetafile( *pSt, aWMF );
 
     if (!bOk || pSt->GetError() || !aWMF.GetActionSize())
         return false;
 
+    //skip duplicate graphics when fuzzing
+    if (utl::ConfigManager::IsFuzzing())
+    {
+        if (m_aGrafPosSet.find(nPosFc) != m_aGrafPosSet.end())
+            return false;
+        m_aGrafPosSet.insert(nPosFc);
+    }
+
     if (m_xWwFib->m_envr != 1) // !MAC as creator
     {
         rpGraphic = new Graphic( aWMF );
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 040c5f995e0c..329cf0acfd28 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1198,6 +1198,11 @@ private:
     */
     std::vector<const SwCharFormat*> m_aRubyCharFormats;
 
+    /*
+    For fuzzing keep track of source offset of inserted graphics
+    */
+    std::set<sal_uLong> m_aGrafPosSet;
+
     WW8PostProcessAttrsInfo * m_pPostProcessAttrsInfo;
 
     std::shared_ptr<WW8Fib> m_xWwFib;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to