summaryrefslogtreecommitdiff
path: root/filter/source/msfilter/svdfppt.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-08-27 09:13:42 +0100
committerAndras Timar <andras.timar@collabora.com>2015-08-31 13:53:03 +0200
commitaecf1513a7b28b6e0127c2f142d6f601b92c694b (patch)
tree5ca0acf992fef1f969b850fbd47ca35947df926a /filter/source/msfilter/svdfppt.cxx
parentb459a9d9700255ea0b6baabacfa3582a3d745ac5 (diff)
extend seek, loop ending tests to ppt specific code
(cherry picked from commit c249f93d96ec87b0acbd25ffe087543d6fe9fb14) Change-Id: Id4419b6b902b742117e248870b6a663c9c58955f Reviewed-on: https://gerrit.libreoffice.org/18053 Reviewed-by: David Tardon <dtardon@redhat.com> Tested-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'filter/source/msfilter/svdfppt.cxx')
-rw-r--r--filter/source/msfilter/svdfppt.cxx45
1 files changed, 21 insertions, 24 deletions
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 0942060f2d36..9a5ca61b76e3 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -706,19 +706,16 @@ void SdrEscherImport::RecolorGraphic( SvStream& rSt, sal_uInt32 nRecLen, Graphic
}
}
-namespace
+sal_uLong DffPropSet::SanitizeEndPos(SvStream &rIn, sal_uLong nEndRecPos)
{
- sal_uLong SanitizeEndPos(SvStream &rIn, sal_uLong nEndRecPos)
+ auto nStreamLen = rIn.Tell() + rIn.remainingSize();
+ if (nEndRecPos > nStreamLen)
{
- auto nStreamLen = rIn.Tell() + rIn.remainingSize();
- if (nEndRecPos > nStreamLen)
- {
- SAL_WARN("filter.ms", "Parsing error: " << nStreamLen <<
- " max end pos, but " << nEndRecPos << " claimed, truncating");
- nEndRecPos = nStreamLen;
- }
- return nEndRecPos;
+ SAL_WARN("filter.ms", "Parsing error: " << nStreamLen <<
+ " max end pos, but " << nEndRecPos << " claimed, truncating");
+ nEndRecPos = nStreamLen;
}
+ return nEndRecPos;
}
/* ProcessObject is called from ImplSdPPTImport::ProcessObj to handle all application specific things,
@@ -2650,7 +2647,7 @@ void ImportComment10( SvxMSDffManager& rMan, SvStream& rStCtrl, SdrPage* pPage,
sal_Int32 nPosY = 0;
- auto nEndRecPos = SanitizeEndPos(rStCtrl, rComment10Hd.GetRecEndFilePos());
+ auto nEndRecPos = DffPropSet::SanitizeEndPos(rStCtrl, rComment10Hd.GetRecEndFilePos());
while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < nEndRecPos ) )
{
DffRecordHeader aCommentHd;
@@ -3192,7 +3189,7 @@ PPTExtParaProv::PPTExtParaProv( SdrPowerPointImport& rMan, SvStream& rSt, const
pListHd->SeekToContent( rSt );
if ( !rMan.SeekToContentOfProgTag( 9, rSt, *pListHd, aContentDataHd ) )
break;
- auto nEndRecPos = SanitizeEndPos(rSt, aContentDataHd.GetRecEndFilePos());
+ auto nEndRecPos = DffPropSet::SanitizeEndPos(rSt, aContentDataHd.GetRecEndFilePos());
while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < nEndRecPos ) )
{
ReadDffRecordHeader( rSt, aHd );
@@ -3200,7 +3197,7 @@ PPTExtParaProv::PPTExtParaProv( SdrPowerPointImport& rMan, SvStream& rSt, const
{
case PPT_PST_ExtendedBuGraContainer :
{
- auto nHdEndRecPos = SanitizeEndPos(rSt, aHd.GetRecEndFilePos());
+ auto nHdEndRecPos = DffPropSet::SanitizeEndPos(rSt, aHd.GetRecEndFilePos());
while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < nHdEndRecPos ) )
{
sal_uInt16 nType;
@@ -3275,7 +3272,7 @@ PPTExtParaProv::PPTExtParaProv( SdrPowerPointImport& rMan, SvStream& rSt, const
{ // get the extended paragraph styles on mainmaster ( graphical bullets, num ruling ... )
if ( !rMan.SeekToContentOfProgTag( 9, rSt, *pHd, aContentDataHd ) )
break;
- auto nEndRecPos = SanitizeEndPos(rSt, aContentDataHd.GetRecEndFilePos());
+ auto nEndRecPos = DffPropSet::SanitizeEndPos(rSt, aContentDataHd.GetRecEndFilePos());
while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < nEndRecPos ) )
{
ReadDffRecordHeader( rSt, aHd );
@@ -3289,7 +3286,7 @@ PPTExtParaProv::PPTExtParaProv( SdrPowerPointImport& rMan, SvStream& rSt, const
rSt.ReadUInt16( nDepth );
if ( i <= 5 )
{
- auto nHdEndRecPos = SanitizeEndPos(rSt, aHd.GetRecEndFilePos());
+ auto nHdEndRecPos = DffPropSet::SanitizeEndPos(rSt, aHd.GetRecEndFilePos());
while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < nHdEndRecPos ) && ( i < nDepth ) )
{
bStyles = true;
@@ -4052,7 +4049,7 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd
{
pEnvHeader->SeekToContent( rIn );
DffRecordHeader aTxMasterStyleHd;
- auto nEndRecPos = SanitizeEndPos(rIn, pEnvHeader->GetRecEndFilePos());
+ auto nEndRecPos = DffPropSet::SanitizeEndPos(rIn, pEnvHeader->GetRecEndFilePos());
while (rIn.Tell() < nEndRecPos)
{
ReadDffRecordHeader( rIn, aTxMasterStyleHd );
@@ -4064,7 +4061,7 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd
sal_uInt16 nLev = 0;
bool bFirst = true;
bFoundTxMasterStyleAtom04 = true;
- auto nTxEndRecPos = SanitizeEndPos(rIn, aTxMasterStyleHd.GetRecEndFilePos());
+ auto nTxEndRecPos = DffPropSet::SanitizeEndPos(rIn, aTxMasterStyleHd.GetRecEndFilePos());
while (rIn.GetError() == 0 && rIn.Tell() < nTxEndRecPos && nLev < nLevelAnz && nLev < nMaxPPTLevels)
{
if ( nLev )
@@ -4103,7 +4100,7 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd
rSlideHd.SeekToContent( rIn );
DffRecordHeader aTxMasterStyleHd;
- auto nEndRecPos = SanitizeEndPos(rIn, rSlideHd.GetRecEndFilePos());
+ auto nEndRecPos = DffPropSet::SanitizeEndPos(rIn, rSlideHd.GetRecEndFilePos());
while (rIn.Tell() < nEndRecPos)
{
ReadDffRecordHeader( rIn, aTxMasterStyleHd );
@@ -4162,7 +4159,7 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd
sal_uInt16 nLev = 0;
bool bFirst = true;
- auto nTxEndRecPos = SanitizeEndPos(rIn, aTxMasterStyleHd.GetRecEndFilePos());
+ auto nTxEndRecPos = DffPropSet::SanitizeEndPos(rIn, aTxMasterStyleHd.GetRecEndFilePos());
while ( rIn.GetError() == 0 && rIn.Tell() < nTxEndRecPos && nLev < nLevelAnz )
{
if ( nLev && ( nInstance < 5 ) )
@@ -4242,7 +4239,7 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd
{
pEnvHeader2->SeekToContent( rIn );
DffRecordHeader aTxMasterStyleHd2;
- auto nEnvEndRecPos = SanitizeEndPos(rIn, pEnvHeader2->GetRecEndFilePos());
+ auto nEnvEndRecPos = DffPropSet::SanitizeEndPos(rIn, pEnvHeader2->GetRecEndFilePos());
while (rIn.Tell() < nEnvEndRecPos)
{
ReadDffRecordHeader( rIn, aTxMasterStyleHd2 );
@@ -4253,7 +4250,7 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd
sal_uInt16 nLev = 0;
bool bFirst = true;
- auto nTxEndRecPos = SanitizeEndPos(rIn, aTxMasterStyleHd2.GetRecEndFilePos());
+ auto nTxEndRecPos = DffPropSet::SanitizeEndPos(rIn, aTxMasterStyleHd2.GetRecEndFilePos());
while ( rIn.GetError() == 0 && rIn.Tell() < nTxEndRecPos && nLev < nLevelAnz )
{
if ( nLev )
@@ -4771,7 +4768,7 @@ bool PPTTextSpecInfoAtomInterpreter::Read( SvStream& rIn, const DffRecordHeader&
sal_uInt32 nCharIdx = 0;
rRecHd.SeekToContent( rIn );
- auto nEndRecPos = SanitizeEndPos(rIn, rRecHd.GetRecEndFilePos());
+ auto nEndRecPos = DffPropSet::SanitizeEndPos(rIn, rRecHd.GetRecEndFilePos());
while (rIn.Tell() < nEndRecPos && rIn.good())
{
if ( nRecordType == PPT_PST_TextSpecInfoAtom )
@@ -5111,7 +5108,7 @@ void PPTStyleTextPropReader::Init( SvStream& rIn, SdrPowerPointImport& rMan, con
{
rIn.Seek( rExtParaHd.nFilePos + 8 );
- auto nEndRecPos = SanitizeEndPos(rIn, rExtParaHd.GetRecEndFilePos());
+ auto nEndRecPos = DffPropSet::SanitizeEndPos(rIn, rExtParaHd.GetRecEndFilePos());
while( ( rIn.GetError() == 0 ) && ( rIn.Tell() < nEndRecPos ) )
{
aStyleTextProp9.resize( aStyleTextProp9.size() + 1 );
@@ -6631,7 +6628,7 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport
// or ParaTabStops and append them on this textobj
rIn.Seek( nFilePos );
::std::vector< PPTFieldEntry* > FieldList;
- auto nEndRecPos = SanitizeEndPos(rIn, aClientTextBoxHd.GetRecEndFilePos());
+ auto nEndRecPos = DffPropSet::SanitizeEndPos(rIn, aClientTextBoxHd.GetRecEndFilePos());
while (rIn.Tell() < nEndRecPos)
{
ReadDffRecordHeader( rIn, aTextHd );