You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ar...@apache.org on 2022/12/09 19:28:50 UTC

[openoffice] branch ppt created (now 272eca8e07)

This is an automated email from the ASF dual-hosted git repository.

ardovm pushed a change to branch ppt
in repository https://gitbox.apache.org/repos/asf/openoffice.git


      at 272eca8e07 Detect some endless loops

This branch includes the following new commits:

     new b622dd6d9d Check validity of page descriptors
     new 908738a448 More checks
     new 272eca8e07 Detect some endless loops

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[openoffice] 01/03: Check validity of page descriptors

Posted by ar...@apache.org.
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 b622dd6d9d2607212ada7fd2dd4e4951e49eb0d6
Author: Arrigo Marchiori <ar...@yahoo.it>
AuthorDate: Fri Dec 9 17:08:24 2022 +0100

    Check validity of page descriptors
---
 main/sd/source/filter/ppt/pptin.cxx | 15 ++++++++++++---
 main/svx/source/svdraw/svdpage.cxx  | 12 ++++++++++++
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/main/sd/source/filter/ppt/pptin.cxx b/main/sd/source/filter/ppt/pptin.cxx
index c79c05ddf9..5d5936ccd6 100644
--- a/main/sd/source/filter/ppt/pptin.cxx
+++ b/main/sd/source/filter/ppt/pptin.cxx
@@ -2487,9 +2487,18 @@ SdrObject* ImplSdPPTImport::ApplyTextObj( PPTTextObj* pTextObj, SdrTextObj* pObj
 
                             if ( ( eAktPageKind != PPT_NOTEPAGE ) && ( pSlideLayout->aPlacementId[ i ] != (sal_uLong)-1 ) )
                             {
-                                SdrObject* pTitleObj = ((SdPage&)pPage->TRG_GetMasterPage()).GetPresObj( PRESOBJ_TITLE );
-                                SdrObject* pOutlineObj = ((SdPage&)pPage->TRG_GetMasterPage()).GetPresObj( PRESOBJ_OUTLINE );
-
+                                SdrObject* pTitleObj;
+                                try {
+                                    pTitleObj = ((SdPage&)pPage->TRG_GetMasterPage()).GetPresObj( PRESOBJ_TITLE );
+                                } catch (uno::Exception &) {
+                                    pTitleObj = NULL;
+                                }
+                                SdrObject* pOutlineObj;
+                                try {
+                                    pOutlineObj = ((SdPage&)pPage->TRG_GetMasterPage()).GetPresObj( PRESOBJ_OUTLINE );
+                                } catch (uno::Exception &) {
+                                    pOutlineObj = NULL;
+                                }
                                 Rectangle aTitleRect;
                                 Rectangle aOutlineRect;
                                 Size      aOutlineSize;
diff --git a/main/svx/source/svdraw/svdpage.cxx b/main/svx/source/svdraw/svdpage.cxx
index 3507bbfb8e..ca12e75818 100644
--- a/main/svx/source/svdraw/svdpage.cxx
+++ b/main/svx/source/svdraw/svdpage.cxx
@@ -1768,24 +1768,36 @@ void SdrPage::TRG_ClearMasterPage()
 SdrPage& SdrPage::TRG_GetMasterPage() const
 {
 	DBG_ASSERT(mpMasterPageDescriptor != 0L, "TRG_GetMasterPage(): No MasterPage available. Use TRG_HasMasterPage() before access (!)");
+        if (mpMasterPageDescriptor == NULL) {
+            throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No master page descriptor")), NULL);
+        }
 	return mpMasterPageDescriptor->GetUsedPage();
 }
 
 const SetOfByte& SdrPage::TRG_GetMasterPageVisibleLayers() const
 {
 	DBG_ASSERT(mpMasterPageDescriptor != 0L, "TRG_GetMasterPageVisibleLayers(): No MasterPage available. Use TRG_HasMasterPage() before access (!)");
+        if (mpMasterPageDescriptor == NULL) {
+            throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No master page descriptor")), NULL);
+        }
 	return mpMasterPageDescriptor->GetVisibleLayers();
 }
 
 void SdrPage::TRG_SetMasterPageVisibleLayers(const SetOfByte& rNew)
 {
 	DBG_ASSERT(mpMasterPageDescriptor != 0L, "TRG_SetMasterPageVisibleLayers(): No MasterPage available. Use TRG_HasMasterPage() before access (!)");
+        if (mpMasterPageDescriptor == NULL) {
+            throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No master page descriptor")), NULL);
+        }
 	mpMasterPageDescriptor->SetVisibleLayers(rNew);
 }
 
 sdr::contact::ViewContact& SdrPage::TRG_GetMasterPageDescriptorViewContact() const
 {
 	DBG_ASSERT(mpMasterPageDescriptor != 0L, "TRG_GetMasterPageDescriptorViewContact(): No MasterPage available. Use TRG_HasMasterPage() before access (!)");
+        if (mpMasterPageDescriptor == NULL) {
+            throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No master page descriptor")), NULL);
+        }
 	return mpMasterPageDescriptor->GetViewContact();
 }
 


[openoffice] 03/03: Detect some endless loops

Posted by ar...@apache.org.
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 <ar...@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 );


[openoffice] 02/03: More checks

Posted by ar...@apache.org.
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 908738a448df22237df99329d2e7141e168737d9
Author: Arrigo Marchiori <ar...@yahoo.it>
AuthorDate: Fri Dec 9 17:43:46 2022 +0100

    More checks
---
 main/svx/source/svdraw/svdoedge.cxx |  2 +-
 main/vcl/source/gdi/bmpacc.cxx      | 53 ++++++++++++++++++++++---------------
 2 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/main/svx/source/svdraw/svdoedge.cxx b/main/svx/source/svdraw/svdoedge.cxx
index 5bd1237c82..73f9c3f1bc 100644
--- a/main/svx/source/svdraw/svdoedge.cxx
+++ b/main/svx/source/svdraw/svdoedge.cxx
@@ -2262,7 +2262,7 @@ void SdrEdgeObj::NbcResize(const Point& rRefPnt, const Fraction& aXFact, const F
 	ResizeXPoly(*pEdgeTrack,rRefPnt,aXFact,aYFact);
 
 	// #75371# if resize is not from paste, forget user distances
-	if(!GetModel()->IsPasteResize())
+	if(GetModel() && !GetModel()->IsPasteResize())
 	{
 		// #75735#
 		aEdgeInfo.aObj1Line2 = Point();
diff --git a/main/vcl/source/gdi/bmpacc.cxx b/main/vcl/source/gdi/bmpacc.cxx
index dd594425dd..49a38cc9f5 100644
--- a/main/vcl/source/gdi/bmpacc.cxx
+++ b/main/vcl/source/gdi/bmpacc.cxx
@@ -107,31 +107,40 @@ void BitmapReadAccess::ImplCreate( Bitmap& rBitmap )
 			const long	nHeight = mpBuffer->mnHeight;
 			Scanline	pTmpLine = mpBuffer->mpBits;
 
-			mpScanBuf = new Scanline[ nHeight ];
-			maColorMask = mpBuffer->maColorMask;
+            try {
+                mpScanBuf = new Scanline[ nHeight ];
+            } catch (std::bad_alloc &) {
+                mpScanBuf = NULL;
+            }
+            if (mpScanBuf) {
+                maColorMask = mpBuffer->maColorMask;
 
-			if( BMP_SCANLINE_ADJUSTMENT( mpBuffer->mnFormat ) == BMP_FORMAT_TOP_DOWN )
-			{
-				for( long nY = 0L; nY < nHeight; nY++, pTmpLine += mpBuffer->mnScanlineSize )
-					mpScanBuf[ nY ] = pTmpLine;
-			}
-			else
-			{
-				for( long nY = nHeight - 1; nY >= 0; nY--, pTmpLine += mpBuffer->mnScanlineSize )
-					mpScanBuf[ nY ] = pTmpLine;
-			}
+                if( BMP_SCANLINE_ADJUSTMENT( mpBuffer->mnFormat ) == BMP_FORMAT_TOP_DOWN )
+                {
+                    for( long nY = 0L; nY < nHeight; nY++, pTmpLine += mpBuffer->mnScanlineSize )
+                        mpScanBuf[ nY ] = pTmpLine;
+                }
+                else
+                {
+                    for( long nY = nHeight - 1; nY >= 0; nY--, pTmpLine += mpBuffer->mnScanlineSize )
+                        mpScanBuf[ nY ] = pTmpLine;
+                }
 
-			if( !ImplSetAccessPointers( BMP_SCANLINE_FORMAT( mpBuffer->mnFormat ) ) )
-			{
-				delete[] mpScanBuf;
-				mpScanBuf = NULL;
+                if( !ImplSetAccessPointers( BMP_SCANLINE_FORMAT( mpBuffer->mnFormat ) ) )
+                {
+                    delete[] mpScanBuf;
+                    mpScanBuf = NULL;
 
-				pImpBmp->ImplReleaseBuffer( mpBuffer, !mbModify );
-				mpBuffer = NULL;
-			}
-			else
-				maBitmap = rBitmap;
-		}
+                    pImpBmp->ImplReleaseBuffer( mpBuffer, !mbModify );
+                    mpBuffer = NULL;
+                }
+                else
+                    maBitmap = rBitmap;
+            } else {
+                pImpBmp->ImplReleaseBuffer( mpBuffer, !mbModify );
+                mpBuffer = NULL;
+            }
+        }
 	}
 }