Kaydet (Commit) 858257d4 authored tarafından Caolán McNamara's avatar Caolán McNamara

check for ridiculous lengths and check stream status

Change-Id: Iefe943794e005f03b2a6ea5fc642b8c3d21b3334
üst 43691a15
This diff was suppressed by a .gitattributes entry.
...@@ -680,15 +680,21 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt, ...@@ -680,15 +680,21 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
&& maShapeRecords.Current()->nRecLen ) && maShapeRecords.Current()->nRecLen )
{ {
sal_uInt32 nBytesLeft = maShapeRecords.Current()->nRecLen; sal_uInt32 nBytesLeft = maShapeRecords.Current()->nRecLen;
sal_uInt32 nUDData; auto nAvailableBytes = rSt.remainingSize();
sal_uInt16 nPID; if (nBytesLeft > nAvailableBytes)
{
SAL_WARN("sw.ww8", "Document claimed to have shape record of " << nBytesLeft << " bytes, but only " << nAvailableBytes << " available");
nBytesLeft = nAvailableBytes;
}
while( 5 < nBytesLeft ) while( 5 < nBytesLeft )
{ {
rSt.ReadUInt16( nPID ); sal_uInt16 nPID(0);
if ( rSt.GetError() != 0 ) rSt.ReadUInt16(nPID);
sal_uInt32 nUDData(0);
rSt.ReadUInt32(nUDData);
if (!rSt.good())
break; break;
rSt.ReadUInt32( nUDData ); switch (nPID)
switch( nPID )
{ {
case 0x038F: pImpRec->nXAlign = nUDData; break; case 0x038F: pImpRec->nXAlign = nUDData; break;
case 0x0390: case 0x0390:
...@@ -716,8 +722,6 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt, ...@@ -716,8 +722,6 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
pImpRec->isHorizontalRule = true; pImpRec->isHorizontalRule = true;
break; break;
} }
if ( rSt.GetError() != 0 )
break;
nBytesLeft -= 6; nBytesLeft -= 6;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment