incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1362888 - in /incubator/ooo/trunk/main/sc/source/filter: ftools/ftools.cxx inc/ftools.hxx qpro/qpro.cxx
Date Wed, 18 Jul 2012 11:32:39 GMT
Author: alg
Date: Wed Jul 18 11:32:39 2012
New Revision: 1362888

URL: http://svn.apache.org/viewvc?rev=1362888&view=rev
Log:
filter review QuattroPro
Patch by: Eike Rathke

Modified:
    incubator/ooo/trunk/main/sc/source/filter/ftools/ftools.cxx
    incubator/ooo/trunk/main/sc/source/filter/inc/ftools.hxx
    incubator/ooo/trunk/main/sc/source/filter/qpro/qpro.cxx

Modified: incubator/ooo/trunk/main/sc/source/filter/ftools/ftools.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/filter/ftools/ftools.cxx?rev=1362888&r1=1362887&r2=1362888&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/filter/ftools/ftools.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/filter/ftools/ftools.cxx Wed Jul 18 11:32:39 2012
@@ -273,13 +273,17 @@ ByteString ScfTools::ReadCString( SvStre
 {
     ByteString aRet;
     sal_Char cChar;
-
+    
+    sal_uInt32 nLen = 0;
     rStrm >> cChar;
-    while( cChar )
+    while( cChar && nLen++ < STRING_MAXLEN )
     {
         aRet += cChar;
         rStrm >> 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;
 }
 
@@ -288,9 +292,10 @@ ByteString ScfTools::ReadCString( SvStre
     ByteString aRet;
     sal_Char cChar;
 
+    sal_uInt32 nLen = 0;
     rStrm >> cChar;
     rnBytesLeft--;
-    while( cChar )
+    while( cChar && nLen++ < STRING_MAXLEN )
     {
         aRet += cChar;
         rStrm >> cChar;
@@ -300,12 +305,12 @@ ByteString ScfTools::ReadCString( SvStre
     return aRet;
 }
 
-void ScfTools::AppendCString( SvStream& rStrm, ByteString& rString )
+void ScfTools::AppendCStringWithLen( SvStream& rStrm, ByteString& rString, sal_uInt32
nLen )
 {
     sal_Char cChar;
 
     rStrm >> cChar;
-    while( cChar )
+    while( cChar && nLen++ < STRING_MAXLEN )
     {
         rString += cChar;
         rStrm >> cChar;
@@ -315,7 +320,7 @@ void ScfTools::AppendCString( SvStream& 
 void ScfTools::AppendCString( SvStream& rStrm, String& rString, rtl_TextEncoding
eTextEnc )
 {
     ByteString aByteString;
-    AppendCString( rStrm, aByteString );
+    AppendCStringWithLen( rStrm, aByteString, rString.Len() );
     rString += String( aByteString, eTextEnc );
 }
 

Modified: incubator/ooo/trunk/main/sc/source/filter/inc/ftools.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/filter/inc/ftools.hxx?rev=1362888&r1=1362887&r2=1362888&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/filter/inc/ftools.hxx (original)
+++ incubator/ooo/trunk/main/sc/source/filter/inc/ftools.hxx Wed Jul 18 11:32:39 2012
@@ -359,8 +359,13 @@ public:
     inline static String ReadCString( SvStream& rStrm, sal_Int32& rnBytesLeft, rtl_TextEncoding
eTextEnc )
                             { return String( ReadCString( rStrm, rnBytesLeft ), eTextEnc
); }
 
-    /** Appends a zero terminted byte string. */
-    static void         AppendCString( SvStream& rStrm, ByteString& rString );
+    /** Appends a zero terminted byte string.
+        @param nLen
+               The previous length of the string, usually rString.Len(), but 
+               necessary as this may be called from within AppendCString() 
+               where rString is a temporary ByteString to be appended to 
+               UniString. */
+    static void         AppendCStringWithLen( SvStream& rStrm, ByteString& rString,
sal_uInt32 nLen );
     /** Appends a zero terminted byte string. */
     static void         AppendCString( SvStream& rStrm, String& rString, rtl_TextEncoding
eTextEnc );
 

Modified: incubator/ooo/trunk/main/sc/source/filter/qpro/qpro.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/filter/qpro/qpro.cxx?rev=1362888&r1=1362887&r2=1362888&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/filter/qpro/qpro.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/filter/qpro/qpro.cxx Wed Jul 18 11:32:39 2012
@@ -61,10 +61,16 @@ FltError ScQProReader::readSheet( SCTAB 
             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
), (sal_Bool) sal_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 ), (sal_Bool) sal_True );
+                }
+                else
+                    eRet = eERR_FORMAT;
                 }
                 break;
 
@@ -192,7 +198,11 @@ FltError ScQProReader::import( ScDocumen
                 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++;
                 }



Mime
View raw message