sc/source/filter/ftools/ftools.cxx |   10 +++++++---
 sc/source/filter/qpro/qpro.cxx     |   20 +++++++++++++++-----
 2 files changed, 22 insertions(+), 8 deletions(-)

New commits:
commit 079223a9680c0a0c232c6615203817c4eb147226
Author: Eike Rathke [er] <eike.rat...@oracle.com>
Date:   Tue Jul 31 10:00:56 2012 +0200

    QuattroPro warnings

diff --git a/sc/source/filter/ftools/ftools.cxx 
b/sc/source/filter/ftools/ftools.cxx
index 52f848e..cb224bc 100644
--- a/sc/source/filter/ftools/ftools.cxx
+++ b/sc/source/filter/ftools/ftools.cxx
@@ -280,7 +280,8 @@ ByteString ScfTools::ReadCString( SvStream& rStrm )
 {
     rtl::OStringBuffer aRet;
 
-    while (1)
+    sal_uInt32 nLen = 0;
+    while (nLen++ < STRING_MAXLEN)
     {
         sal_Char cChar(0);
         rStrm >> cChar;
@@ -288,7 +289,9 @@ ByteString ScfTools::ReadCString( SvStream& rStrm )
             break;
         aRet.append(cChar);
     }
-
+    // Callers assume that a 0-byte was read and may advance their book keeping
+    // counters by String.Len()+1, don't put back cChar!=0 if STRING_MAXLEN was
+    // reached.
     return aRet.makeStringAndClear();
 }
 
@@ -296,7 +299,8 @@ ByteString ScfTools::ReadCString( SvStream& rStrm, 
sal_Int32& rnBytesLeft )
 {
     rtl::OStringBuffer aRet;
 
-    while (1)
+    sal_uInt32 nLen = 0;
+    while (nLen++ < STRING_MAXLEN)
     {
         sal_Char cChar(0);
         rStrm >> cChar;
diff --git a/sc/source/filter/qpro/qpro.cxx b/sc/source/filter/qpro/qpro.cxx
index b8ee3ab..8572e66 100644
--- a/sc/source/filter/qpro/qpro.cxx
+++ b/sc/source/filter/qpro/qpro.cxx
@@ -64,10 +64,16 @@ FltError ScQProReader::readSheet( SCTAB nTab, ScDocument* 
pDoc, ScQProStyle *pSt
             case 0x000f:{ // Label cell
                 String aLabel;
                 *mpStream >> nCol >> nDummy >> nRow >> nStyle >> nDummy;
-                readString( aLabel, getLength() - 7 );
-                nStyle = nStyle >> 3;
-                pStyle->SetFormat( pDoc, nCol, nRow, nTab, nStyle );
-                pDoc->PutCell( nCol, nRow, nTab, ScBaseCell::CreateTextCell( 
aLabel, pDoc ), true );
+                sal_uInt16 nLen = getLength();
+                if (nLen >= 7)
+                {
+                    readString( aLabel, nLen - 7 );
+                    nStyle = nStyle >> 3;
+                    pStyle->SetFormat( pDoc, nCol, nRow, nTab, nStyle );
+                    pDoc->PutCell( nCol, nRow, nTab, 
ScBaseCell::CreateTextCell( aLabel, pDoc ), true );
+                }
+                else
+                    eRet = eERR_FORMAT;
                 }
                 break;
 
@@ -195,7 +201,11 @@ FltError ScQProReader::import( ScDocument *pDoc )
                 String aLabel;
                 *mpStream >> nPtSize >> nFontAttr;
                 pStyleElement->setFontRecord( j, nFontAttr, nPtSize );
-                readString( aLabel, getLength() - 4 );
+                sal_uInt16 nLen = getLength();
+                if (nLen >= 4)
+                    readString( aLabel, nLen - 4 );
+                else
+                    eRet = eERR_FORMAT;
                 pStyleElement->setFontType( j, aLabel );
                 j++;
                 }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to