Kaydet (Commit) 04d34c63 authored tarafından Caolán McNamara's avatar Caolán McNamara

coverity#1242688 Untrusted loop bound

Change-Id: Ic3e2c390de22d3e998daf760d73619218da020ec
üst d4617ef9
...@@ -4507,7 +4507,9 @@ PPTTextRulerInterpreter::PPTTextRulerInterpreter( sal_uInt32 nFileOfs, SdrPowerP ...@@ -4507,7 +4507,9 @@ PPTTextRulerInterpreter::PPTTextRulerInterpreter( sal_uInt32 nFileOfs, SdrPowerP
} }
if ( nFileOfs ) if ( nFileOfs )
{ {
sal_Int16 nTCount; bool bRecordOk = true;
sal_Int16 nTCount(0);
sal_Int32 i; sal_Int32 i;
rIn.ReadInt32( mpImplRuler->nFlags ); rIn.ReadInt32( mpImplRuler->nFlags );
...@@ -4518,10 +4520,16 @@ PPTTextRulerInterpreter::PPTTextRulerInterpreter( sal_uInt32 nFileOfs, SdrPowerP ...@@ -4518,10 +4520,16 @@ PPTTextRulerInterpreter::PPTTextRulerInterpreter( sal_uInt32 nFileOfs, SdrPowerP
rIn.ReadUInt16( mpImplRuler->nDefaultTab ); rIn.ReadUInt16( mpImplRuler->nDefaultTab );
if ( mpImplRuler->nFlags & 4 ) if ( mpImplRuler->nFlags & 4 )
{ {
rIn.ReadInt16( nTCount ); rIn.ReadInt16(nTCount);
if ( nTCount )
const size_t nMaxPossibleRecords = rIn.remainingSize() / (2*sizeof(sal_uInt16));
const sal_uInt16 nTabCount(nTCount);
bRecordOk = nTabCount <= nMaxPossibleRecords;
if (nTCount && bRecordOk)
{ {
mpImplRuler->nTabCount = (sal_uInt16)nTCount; mpImplRuler->nTabCount = nTabCount;
mpImplRuler->pTab = new PPTTabEntry[ mpImplRuler->nTabCount ]; mpImplRuler->pTab = new PPTTabEntry[ mpImplRuler->nTabCount ];
for ( i = 0; i < nTCount; i++ ) for ( i = 0; i < nTCount; i++ )
{ {
...@@ -4530,23 +4538,27 @@ PPTTextRulerInterpreter::PPTTextRulerInterpreter( sal_uInt32 nFileOfs, SdrPowerP ...@@ -4530,23 +4538,27 @@ PPTTextRulerInterpreter::PPTTextRulerInterpreter( sal_uInt32 nFileOfs, SdrPowerP
} }
} }
} }
for ( i = 0; i < 5; i++ )
if (bRecordOk)
{ {
if ( mpImplRuler->nFlags & ( 8 << i ) ) for ( i = 0; i < 5; i++ )
rIn.ReadUInt16( mpImplRuler->nTextOfs[ i ] );
if ( mpImplRuler->nFlags & ( 256 << i ) )
rIn.ReadUInt16( mpImplRuler->nBulletOfs[ i ] );
if( mpImplRuler->nBulletOfs[ i ] > 0x7fff)
{ {
// workaround if ( mpImplRuler->nFlags & ( 8 << i ) )
// when bullet offset is > 0x7fff, the paragraph should look like rIn.ReadUInt16( mpImplRuler->nTextOfs[ i ] );
// * first line text if ( mpImplRuler->nFlags & ( 256 << i ) )
// second line text rIn.ReadUInt16( mpImplRuler->nBulletOfs[ i ] );
if( mpImplRuler->nBulletOfs[ i ] > 0x7fff)
// we add to bullet para indent 0xffff - bullet offset. it looks like {
// best we can do for now // workaround
mpImplRuler->nTextOfs[ i ] += 0xffff - mpImplRuler->nBulletOfs[ i ]; // when bullet offset is > 0x7fff, the paragraph should look like
mpImplRuler->nBulletOfs[ i ] = 0; // * first line text
// second line text
// we add to bullet para indent 0xffff - bullet offset. it looks like
// best we can do for now
mpImplRuler->nTextOfs[ i ] += 0xffff - mpImplRuler->nBulletOfs[ i ];
mpImplRuler->nBulletOfs[ i ] = 0;
}
} }
} }
} }
......
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