[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - filter/source sd/qa sd/source

Caolán McNamara caolanm at redhat.com
Sat Aug 29 01:32:46 PDT 2015


 filter/source/msfilter/svdfppt.cxx   |   62 ++++++++++++++++++++++++-----------
 sd/qa/unit/data/ppt/pass/hang-15.ppt |binary
 sd/qa/unit/data/ppt/pass/hang-16.ppt |binary
 sd/qa/unit/data/ppt/pass/hang-17.ppt |binary
 sd/source/filter/ppt/pptin.cxx       |   29 +++++++++++-----
 sd/source/filter/ppt/propread.cxx    |   21 ++++++-----
 6 files changed, 76 insertions(+), 36 deletions(-)

New commits:
commit b45df6e4037556c3ee6ccdb4497762884fdb2327
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Aug 28 08:28:51 2015 +0100

    check seeks and reads
    
    Change-Id: I0c5c4784713376e0762bfbd197640f8d31b65562
    (cherry picked from commit 1847753ab135f522df6a293a8539155437f0129f)
    Reviewed-on: https://gerrit.libreoffice.org/18116
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 40c3349..e1e14b8 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -782,7 +782,8 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi
                     }
                     break;
                 }
-                aClientDataHd.SeekToEndOfRecord( rSt );
+                if (!aClientDataHd.SeekToEndOfRecord(rSt))
+                    break;
             }
         }
         if ( ( aPlaceholderAtom.nPlaceholderId == PPT_PLACEHOLDER_NOTESSLIDEIMAGE ) && ( rPersistEntry.bNotesMaster == false ) )
@@ -1798,7 +1799,10 @@ SdrObject* SdrPowerPointImport::ImportOLE( long nOLEId,
                 break;
             }
             else
-                aPlaceHd.SeekToEndOfRecord( rStCtrl );
+            {
+                if (!aPlaceHd.SeekToEndOfRecord(rStCtrl))
+                    break;
+            }
         }
     }
 
@@ -2390,7 +2394,8 @@ bool SdrPowerPointImport::SeekToContentOfProgTag( sal_Int32 nVersion, SvStream&
                     }
                 }
             }
-            aProgTagBinaryDataHd.SeekToEndOfRecord( rSt );
+            if (!aProgTagBinaryDataHd.SeekToEndOfRecord(rSt))
+                break;
         }
     }
     if ( !bRetValue )
@@ -2691,7 +2696,8 @@ void ImportComment10( SvxMSDffManager& rMan, SvStream& rStCtrl, SdrPage* pPage,
             }
             break;
         }
-        aCommentHd.SeekToEndOfRecord( rStCtrl );
+        if (!aCommentHd.SeekToEndOfRecord(rStCtrl))
+            break;
     }
     Point aPosition( nPosX, nPosY );
     rMan.Scale( aPosition );
@@ -2751,7 +2757,8 @@ void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry*
                         while( ( rStCtrl.GetError() == 0 ) && SeekToRec( rStCtrl, PPT_PST_Comment10, aContentDataHd.GetRecEndFilePos(), &aComment10Hd ) )
                         {
                             ImportComment10( *this, rStCtrl, pRet, aComment10Hd );
-                            aComment10Hd.SeekToEndOfRecord( rStCtrl );
+                            if (!aComment10Hd.SeekToEndOfRecord(rStCtrl))
+                                break;
                         }
                     }
                 }
@@ -2829,7 +2836,8 @@ void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry*
                             }
                             if ( aEscherObjListHd.nRecType == DFF_msofbtSpContainer )
                                 break;
-                            aEscherObjListHd.SeekToEndOfRecord( rStCtrl );
+                            if (!aEscherObjListHd.SeekToEndOfRecord(rStCtrl))
+                                break;
                         }
 
                         // now importing page
@@ -2879,7 +2887,8 @@ void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry*
                             }
                             if ( aEscherObjListHd.nRecType == DFF_msofbtSpgrContainer )
                                 break;
-                            aEscherObjListHd.SeekToEndOfRecord( rStCtrl );
+                            if (!aEscherObjListHd.SeekToEndOfRecord(rStCtrl))
+                                break;
                         }
 
                         if ( rSlidePersist.pBObj )
@@ -2895,7 +2904,8 @@ void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry*
                 }
                 break;
             }
-            aHd.SeekToEndOfRecord( rStCtrl );
+            if (!aHd.SeekToEndOfRecord(rStCtrl))
+                break;
         }
         if ( rSlidePersist.pSolverContainer )
             SolveSolver( *rSlidePersist.pSolverContainer );
@@ -3115,7 +3125,8 @@ void SdrEscherImport::ImportHeaderFooterContainer( DffRecordHeader& rHd, HeaderF
             }
             break;
         }
-        aHd.SeekToEndOfRecord( rStCtrl );
+        if (!aHd.SeekToEndOfRecord(rStCtrl))
+            break;
     }
 }
 
@@ -3253,7 +3264,8 @@ PPTExtParaProv::PPTExtParaProv( SdrPowerPointImport& rMan, SvStream& rSt, const
 #ifdef DBG_UTIL
                         else OSL_FAIL( "PPTExParaProv::PPTExParaProv - unknown atom interpreting the PPT_PST_ExtendedBuGraContainer (SJ)" );
 #endif
-                        aBuGraAtomHd.SeekToEndOfRecord( rSt );
+                        if (!aBuGraAtomHd.SeekToEndOfRecord(rSt))
+                            break;
                     }
                     if ( !aBuGraList.empty() )
                         bGraphics = true;
@@ -3277,7 +3289,8 @@ PPTExtParaProv::PPTExtParaProv( SdrPowerPointImport& rMan, SvStream& rSt, const
                 break;
 #endif
             }
-            aHd.SeekToEndOfRecord( rSt );
+            if (!aHd.SeekToEndOfRecord(rSt))
+                break;
         }
         break;
     }
@@ -3329,7 +3342,8 @@ PPTExtParaProv::PPTExtParaProv( SdrPowerPointImport& rMan, SvStream& rSt, const
                 case 0xf144 :
                 break;
             }
-            aHd.SeekToEndOfRecord( rSt );
+            if (!aHd.SeekToEndOfRecord(rSt))
+                break;
         }
         break;
     }
@@ -4107,7 +4121,10 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd
                 break;
             }
             else
-                aTxMasterStyleHd.SeekToEndOfRecord( rIn );
+            {
+                if (!aTxMasterStyleHd.SeekToEndOfRecord(rIn))
+                    break;
+            }
         }
     }
 
@@ -4121,7 +4138,10 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd
         if ( aTxMasterStyleHd.nRecType == PPT_PST_TxMasterStyleAtom )
             break;
         else
-            aTxMasterStyleHd.SeekToEndOfRecord( rIn );
+        {
+            if (!aTxMasterStyleHd.SeekToEndOfRecord(rIn))
+                break;
+        }
     }
     while ( ( aTxMasterStyleHd.nRecType == PPT_PST_TxMasterStyleAtom ) && ( rIn.Tell() < nEndRecPos ) ) //TODO: aTxMasterStyleHd may be used without having been properly initialized
     {
@@ -4223,7 +4243,8 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd
             }
 #endif
         }
-        aTxMasterStyleHd.SeekToEndOfRecord( rIn );
+        if (!aTxMasterStyleHd.SeekToEndOfRecord(rIn))
+            break;
         ReadDffRecordHeader( rIn, aTxMasterStyleHd );
     }
     if ( !mpCharSheet[ TSS_TYPE_SUBTITLE ] )
@@ -4296,7 +4317,10 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd
                     break;
                 }
                 else
-                    aTxMasterStyleHd2.SeekToEndOfRecord( rIn );
+                {
+                    if (!aTxMasterStyleHd2.SeekToEndOfRecord(rIn))
+                        break;
+                }
             }
         }
     }
@@ -6488,7 +6512,8 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport
 
                                 if ( ( nTmpSlideId == nSlideId ) && ( pHd->nRecInstance == nRefNum ) )
                                 {
-                                    pHd->SeekToEndOfRecord( rIn );
+                                    if (!pHd->SeekToEndOfRecord(rIn))
+                                        break;
                                     ReadDffRecordHeader( rIn, aPresRuleHd );
                                     if ( aPresRuleHd.nRecType == PPT_PST_ExtendedParagraphAtom )
                                     {
@@ -6819,7 +6844,8 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport
                                     }
                                     break;
                                 }
-                                aTextHd.SeekToEndOfRecord( rIn );
+                                if (!aTextHd.SeekToEndOfRecord(rIn))
+                                    break;
                                 if ( pEntry )
                                 {
                                     // sorting fields ( hi >> lo )
diff --git a/sd/qa/unit/data/ppt/pass/hang-15.ppt b/sd/qa/unit/data/ppt/pass/hang-15.ppt
new file mode 100644
index 0000000..b93255a
Binary files /dev/null and b/sd/qa/unit/data/ppt/pass/hang-15.ppt differ
diff --git a/sd/qa/unit/data/ppt/pass/hang-16.ppt b/sd/qa/unit/data/ppt/pass/hang-16.ppt
new file mode 100644
index 0000000..c398d2b
Binary files /dev/null and b/sd/qa/unit/data/ppt/pass/hang-16.ppt differ
diff --git a/sd/qa/unit/data/ppt/pass/hang-17.ppt b/sd/qa/unit/data/ppt/pass/hang-17.ppt
new file mode 100644
index 0000000..de876ff
Binary files /dev/null and b/sd/qa/unit/data/ppt/pass/hang-17.ppt differ
diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index 5fe2bdc..e5b15df 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -519,7 +519,8 @@ bool ImplSdPPTImport::Import()
                     break;
                 rStCtrl.SeekRel( 8 );
                 rStCtrl.ReadUInt32( pPtr->nIndex );
-                aHyperE.SeekToEndOfRecord( rStCtrl );
+                if (!aHyperE.SeekToEndOfRecord(rStCtrl))
+                    break;
             }
         }
     }
@@ -818,7 +819,8 @@ bool ImplSdPPTImport::Import()
                                             }
                                             break;
                                         }
-                                        aProgTagContentHd.SeekToEndOfRecord( rStCtrl );
+                                        if (!aProgTagContentHd.SeekToEndOfRecord(rStCtrl))
+                                            break;
                                     }
                                 }
                             }
@@ -945,7 +947,8 @@ bool ImplSdPPTImport::Import()
                                             case PPT_PST_SlideTime10Atom :  // ??? don't know, this atom is always 8 bytes big
                                             break;                          // and is appearing in nearly every l10 progtag
                                         }
-                                        aProgTagContentHd.SeekToEndOfRecord( rStCtrl );
+                                        if (!aProgTagContentHd.SeekToEndOfRecord(rStCtrl))
+                                            break;
                                     }
                                 }
                             }
@@ -957,7 +960,8 @@ bool ImplSdPPTImport::Import()
                             break;
                         }
 
-                        aHd.SeekToEndOfRecord( rStCtrl );
+                        if (!aHd.SeekToEndOfRecord(rStCtrl))
+                            break;
                     }
                     ImportPageEffect( (SdPage*)pPage, bNewAnimationsUsed );
                 }
@@ -1780,7 +1784,8 @@ void ImplSdPPTImport::ImportPageEffect( SdPage* pPage, const bool bNewAnimations
                             }
                         }
                     }
-                    aHd.SeekToEndOfRecord( rStCtrl );
+                    if (!aHd.SeekToEndOfRecord(rStCtrl))
+                        break;
                 }
                 if ( bTryTwice && ( bSSSlideInfoAtom == false ) )
                 {
@@ -1942,7 +1947,10 @@ OUString ImplSdPPTImport::ReadSound(sal_uInt32 nSoundRef) const
                     }
                 }
                 if ( !bDone )
-                    aSoundRecHd.SeekToEndOfRecord( rStCtrl );
+                {
+                    if (!aSoundRecHd.SeekToEndOfRecord(rStCtrl))
+                        break;
+                }
             }
         }
     }
@@ -2002,7 +2010,8 @@ OUString ImplSdPPTImport::ReadMedia( sal_uInt32 nMediaRef ) const
                                         }
                                         break;
                                     }
-                                    aHd.SeekToEndOfRecord( rStCtrl );
+                                    if (!aHd.SeekToEndOfRecord(rStCtrl))
+                                        break;
                                 }
                                 break;
                             }
@@ -2011,7 +2020,8 @@ OUString ImplSdPPTImport::ReadMedia( sal_uInt32 nMediaRef ) const
                 }
                 break;
             }
-            aHdMovie.SeekToEndOfRecord( rStCtrl );
+            if (!aHdMovie.SeekToEndOfRecord(rStCtrl))
+                break;
         }
     }
     return aRetVal;
@@ -2660,7 +2670,8 @@ SdrObject* ImplSdPPTImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi
                         }
                         break;
                     }
-                    aHd.SeekToEndOfRecord( rSt );
+                    if (!aHd.SeekToEndOfRecord(rSt))
+                        break;
                 }
                 while( ( rSt.GetError() == 0 ) && ( rSt.Tell() < nClientDataLen ) );
 
diff --git a/sd/source/filter/ppt/propread.cxx b/sd/source/filter/ppt/propread.cxx
index 8f376fd..54807ef 100644
--- a/sd/source/filter/ppt/propread.cxx
+++ b/sd/source/filter/ppt/propread.cxx
@@ -319,7 +319,7 @@ bool Section::GetDictionary( Dictionary& rDict )
 
 void Section::Read( SvStorageStream *pStrm )
 {
-    sal_uInt32 i, nSecOfs, nPropSize, nStrmSize;
+    sal_uInt32 nSecOfs, nPropSize, nStrmSize;
     nSecOfs = pStrm->Tell();
 
     pStrm->Seek( STREAM_SEEK_TO_END );
@@ -357,7 +357,7 @@ void Section::Read( SvStorageStream *pStrm )
 
             bool bVariant = ( nPropType == VT_VARIANT );
 
-            for ( i = 0; nPropSize && ( i < nVectorCount ); i++ )
+            for (sal_uInt32 i = 0; nPropSize && ( i < nVectorCount ); ++i)
             {
                 if ( bVariant )
                 {
@@ -453,7 +453,7 @@ void Section::Read( SvStorageStream *pStrm )
                 if( nPropSize > nSecSize - nSecOfs )
                     nPropSize = nSecSize - nSecOfs;
                 sal_uInt8* pBuf = new sal_uInt8[ nPropSize ];
-                pStrm->Read( pBuf, nPropSize );
+                nPropSize = pStrm->Read(pBuf, nPropSize);
                 AddProperty( nPropId, pBuf, nPropSize );
                 delete[] pBuf;
             }
@@ -488,14 +488,17 @@ void Section::Read( SvStorageStream *pStrm )
         }
         else
         {
-            sal_uInt32 nDictCount, nSize;
-            pStrm->ReadUInt32( nDictCount );
-            for ( i = 0; i < nDictCount; i++ )
+            sal_uInt32 nDictCount(0);
+            pStrm->ReadUInt32(nDictCount);
+            for (sal_uInt32 i = 0; i < nDictCount; ++i)
             {
+                sal_uInt32 nSize(0);
                 pStrm->ReadUInt32( nSize ).ReadUInt32( nSize );
-                pStrm->SeekRel( nSize );
+                sal_uInt64 nPos = pStrm->Tell() + nSize;
+                if (nPos != pStrm->Seek(nPos))
+                    break;
             }
-            nSize = pStrm->Tell();
+            sal_uInt32 nSize = pStrm->Tell();
             pStrm->Seek( nPropOfs + nSecOfs );
             nSize -= pStrm->Tell();
             if ( nSize > nStrmSize )
@@ -504,7 +507,7 @@ void Section::Read( SvStorageStream *pStrm )
                 break;
             }
             sal_uInt8* pBuf = new sal_uInt8[ nSize ];
-            pStrm->Read( pBuf, nSize );
+            nSize = pStrm->Read(pBuf, nSize);
             AddProperty( 0xffffffff, pBuf, nSize );
             delete[] pBuf;
         }


More information about the Libreoffice-commits mailing list