This is an automated email from the ASF dual-hosted git repository. ardovm pushed a commit to branch ppt in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 272eca8e075d834a9a9235a4c9e52e17c2276f2f Author: Arrigo Marchiori <ard...@yahoo.it> AuthorDate: Fri Dec 9 18:24:25 2022 +0100 Detect some endless loops --- main/filter/source/msfilter/msdffimp.cxx | 6 ++++++ main/filter/source/msfilter/svdfppt.cxx | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/main/filter/source/msfilter/msdffimp.cxx b/main/filter/source/msfilter/msdffimp.cxx index 4ae3526a04..398b0fcdde 100644 --- a/main/filter/source/msfilter/msdffimp.cxx +++ b/main/filter/source/msfilter/msdffimp.cxx @@ -3025,12 +3025,18 @@ void DffRecordManager::Consume( SvStream& rIn, sal_Bool bAppend, sal_uInt32 nStO pCList = (DffRecordList*)this; while ( pCList->pNext ) pCList = pCList->pNext; + sal_Size nLastPosition; while ( ( rIn.GetError() == 0 ) && ( ( rIn.Tell() + 8 ) <= nStOfs ) ) { + nLastPosition = rIn.Tell(); if ( pCList->nCount == DFF_RECORD_MANAGER_BUF_SIZE ) pCList = new DffRecordList( pCList ); rIn >> pCList->mHd[ pCList->nCount ]; pCList->mHd[ pCList->nCount++ ].SeekToEndOfRecord( rIn ); + if (rIn.Tell() == nLastPosition) { + // We are inside an endless loop + break; + } } rIn.Seek( nOldPos ); } diff --git a/main/filter/source/msfilter/svdfppt.cxx b/main/filter/source/msfilter/svdfppt.cxx index b0571fabb1..86fbab9a12 100644 --- a/main/filter/source/msfilter/svdfppt.cxx +++ b/main/filter/source/msfilter/svdfppt.cxx @@ -2954,8 +2954,10 @@ void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry* rSlidePersist.pHeaderFooterEntry = new HeaderFooterEntry( pMasterPersist ); ProcessData aProcessData( rSlidePersist, (SdPage*)pRet ); + sal_Size nLastPosition; while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aPageHd.GetRecEndFilePos() ) ) { + nLastPosition = rStCtrl.Tell(); DffRecordHeader aHd; rStCtrl >> aHd; switch ( aHd.nRecType ) @@ -3062,9 +3064,11 @@ void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry* DffRecordHeader aShapeHd; if ( SeekToRec( rStCtrl, DFF_msofbtSpContainer, aEscherObjListHd.GetRecEndFilePos(), &aShapeHd ) ) { + sal_Size nShapeLastPosition; aShapeHd.SeekToEndOfRecord( rStCtrl ); while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aEscherObjListHd.GetRecEndFilePos() ) ) { + nShapeLastPosition = rStCtrl.Tell(); rStCtrl >> aShapeHd; if ( ( aShapeHd.nRecType == DFF_msofbtSpContainer ) || ( aShapeHd.nRecType == DFF_msofbtSpgrContainer ) ) { @@ -3085,6 +3089,10 @@ void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry* } } aShapeHd.SeekToEndOfRecord( rStCtrl ); + if (rStCtrl.Tell() == nShapeLastPosition) { + // We are inside an endless loop + break; + } } } } @@ -3137,6 +3145,10 @@ void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry* break; } aHd.SeekToEndOfRecord( rStCtrl ); + if (rStCtrl.Tell() == nLastPosition) { + // We are inside an endless loop + break; + } } if ( rSlidePersist.pSolverContainer ) SolveSolver( *rSlidePersist.pSolverContainer );