[Libreoffice-commits] core.git: sc/source

Caolán McNamara caolanm at redhat.com
Thu Feb 1 15:39:36 UTC 2018


 sc/source/ui/docshell/impex.cxx |   27 ++++++++++++++++-----------
 sc/source/ui/inc/impex.hxx      |    1 +
 2 files changed, 17 insertions(+), 11 deletions(-)

New commits:
commit 2525d7cdea8905aa2120ce7b8ed6b8c793045d70
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Feb 1 15:36:54 2018 +0000

    ofz#3032 slk fuzzing timeouts on filling all rows
    
    which tells us that we're way too slow, which isn't really interesting news,
    set an arbitrary limit for number of rows to import
    
    Change-Id: Ie835088eab4e363a7deb19e9e5dbe43c1838520b

diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index c66d4c7e9bf9..56004800a96c 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -55,6 +55,7 @@
 #include <globstr.hrc>
 #include <o3tl/safeint.hxx>
 #include <tools/svlibrary.h>
+#include <unotools/configmgr.hxx>
 #include <vcl/svapp.hxx>
 
 #include <memory>
@@ -92,7 +93,8 @@ enum class SylkVersion
 // Whole document without Undo
 ScImportExport::ScImportExport( ScDocument* p )
     : pDocSh( dynamic_cast< ScDocShell* >(p->GetDocumentShell()) ), pDoc( p ),
-      nSizeLimit( 0 ), cSep( '\t' ), cStr( '"' ),
+      nSizeLimit( 0 ), nMaxImportRow(!utl::ConfigManager::IsFuzzing() ? MAXROW : SCROWS32K),
+      cSep( '\t' ), cStr( '"' ),
       bFormulas( false ), bIncludeFiltered( true ),
       bAll( true ), bSingle( true ), bUndo( false ),
       bOverflowRow( false ), bOverflowCol( false ), bOverflowCell( false ),
@@ -107,7 +109,8 @@ ScImportExport::ScImportExport( ScDocument* p )
 ScImportExport::ScImportExport( ScDocument* p, const ScAddress& rPt )
     : pDocSh( dynamic_cast< ScDocShell* >(p->GetDocumentShell()) ), pDoc( p ),
       aRange( rPt ),
-      nSizeLimit( 0 ), cSep( '\t' ), cStr( '"' ),
+      nSizeLimit( 0 ), nMaxImportRow(!utl::ConfigManager::IsFuzzing() ? MAXROW : SCROWS32K),
+      cSep( '\t' ), cStr( '"' ),
       bFormulas( false ), bIncludeFiltered( true ),
       bAll( false ), bSingle( true ), bUndo( pDocSh != nullptr ),
       bOverflowRow( false ), bOverflowCol( false ), bOverflowCell( false ),
@@ -123,7 +126,8 @@ ScImportExport::ScImportExport( ScDocument* p, const ScAddress& rPt )
 ScImportExport::ScImportExport( ScDocument* p, const ScRange& r )
     : pDocSh( dynamic_cast<ScDocShell* >(p->GetDocumentShell()) ), pDoc( p ),
       aRange( r ),
-      nSizeLimit( 0 ), cSep( '\t' ), cStr( '"' ),
+      nSizeLimit( 0 ), nMaxImportRow(!utl::ConfigManager::IsFuzzing() ? MAXROW : SCROWS32K),
+      cSep( '\t' ), cStr( '"' ),
       bFormulas( false ), bIncludeFiltered( true ),
       bAll( false ), bSingle( false ), bUndo( pDocSh != nullptr ),
       bOverflowRow( false ), bOverflowCol( false ), bOverflowCell( false ),
@@ -140,7 +144,8 @@ ScImportExport::ScImportExport( ScDocument* p, const ScRange& r )
 // If a View exists, the TabNo of the view will be used.
 ScImportExport::ScImportExport( ScDocument* p, const OUString& rPos )
     : pDocSh( dynamic_cast< ScDocShell* >(p->GetDocumentShell()) ), pDoc( p ),
-      nSizeLimit( 0 ), cSep( '\t' ), cStr( '"' ),
+      nSizeLimit( 0 ), nMaxImportRow(!utl::ConfigManager::IsFuzzing() ? MAXROW : SCROWS32K),
+      cSep( '\t' ), cStr( '"' ),
       bFormulas( false ), bIncludeFiltered( true ),
       bAll( false ), bSingle( true ), bUndo( pDocSh != nullptr ),
       bOverflowRow( false ), bOverflowCol( false ), bOverflowCell( false ),
@@ -1796,10 +1801,10 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm )
                         {
                             bInvalidRow = false;
                             bool bFail = o3tl::checked_add(OUString(p).toInt32(), nStartRow - 1, nRow);
-                            if (bFail || nRow < 0 || MAXROW < nRow)
+                            if (bFail || nRow < 0 || nMaxImportRow < nRow)
                             {
                                 SAL_WARN("sc.ui","ScImportExport::Sylk2Doc - ;Y invalid nRow=" << nRow);
-                                nRow = std::max<SCROW>(0, std::min<SCROW>(nRow, MAXROW));
+                                nRow = std::max<SCROW>(0, std::min<SCROW>(nRow, nMaxImportRow));
                                 bInvalidRow = bOverflowRow = true;
                             }
                             break;
@@ -1820,10 +1825,10 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm )
                         {
                             bInvalidRefRow = false;
                             bool bFail = o3tl::checked_add(OUString(p).toInt32(), nStartRow - 1, nRefRow);
-                            if (bFail || nRefRow < 0 || MAXROW < nRefRow)
+                            if (bFail || nRefRow < 0 || nMaxImportRow < nRefRow)
                             {
                                 SAL_WARN("sc.ui","ScImportExport::Sylk2Doc - ;R invalid nRefRow=" << nRefRow);
-                                nRefRow = std::max<SCROW>(0, std::min<SCROW>(nRefRow, MAXROW));
+                                nRefRow = std::max<SCROW>(0, std::min<SCROW>(nRefRow, nMaxImportRow));
                                 bInvalidRefRow = bOverflowRow = true;
                             }
                             break;
@@ -1833,7 +1838,7 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm )
                             if( !bSingle &&
                                     ( nCol < nStartCol || nCol > nEndCol
                                       || nRow < nStartRow || nRow > nEndRow
-                                      || nCol > MAXCOL || nRow > MAXROW
+                                      || nCol > MAXCOL || nRow > nMaxImportRow
                                       || bInvalidCol || bInvalidRow ) )
                                 break;
                             if( !bData )
@@ -1957,10 +1962,10 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm )
                         {
                             bInvalidRow = false;
                             bool bFail = o3tl::checked_add(OUString(p).toInt32(), nStartRow - 1, nRow);
-                            if (bFail || nRow < 0 || MAXROW < nRow)
+                            if (bFail || nRow < 0 || nMaxImportRow < nRow)
                             {
                                 SAL_WARN("sc.ui","ScImportExport::Sylk2Doc - ;Y invalid nRow=" << nRow);
-                                nRow = std::max<SCROW>(0, std::min<SCROW>(nRow, MAXROW));
+                                nRow = std::max<SCROW>(0, std::min<SCROW>(nRow, nMaxImportRow));
                                 bInvalidRow = bOverflowRow = true;
                             }
                             break;
diff --git a/sc/source/ui/inc/impex.hxx b/sc/source/ui/inc/impex.hxx
index 29361313471d..a143f067494a 100644
--- a/sc/source/ui/inc/impex.hxx
+++ b/sc/source/ui/inc/impex.hxx
@@ -54,6 +54,7 @@ class ScImportExport
     OUString    aNonConvertibleChars;
     OUString    maFilterOptions;
     sal_uLong   nSizeLimit;
+    SCROW       nMaxImportRow;
     sal_Unicode cSep;                   // Separator
     sal_Unicode cStr;                   // String Delimiter
     bool        bFormulas;              // Formula in Text?


More information about the Libreoffice-commits mailing list