Kaydet (Commit) 11a514e0 authored tarafından Caolán McNamara's avatar Caolán McNamara

coverity#1242573 Untrusted loop bound

Change-Id: Ic84e57fbfa2b532409865c4364b91be594d252cf
üst 5e2d089f
......@@ -1462,12 +1462,31 @@ bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pStm )
case W_META_POLYGON:
{
sal_uInt16 nPoints;
bool bRecordOk = true;
sal_uInt16 nPoints(0);
pStm->ReadUInt16( nPoints );
for(sal_uInt16 i = 0; i < nPoints; i++ )
if (nPoints > pStm->remainingSize() / (2 * sizeof(sal_uInt16)))
{
GetWinExtMax( ReadPoint(), aBound, nMapMode );
bBoundsDetermined = true;
bRecordOk = false;
}
else
{
for(sal_uInt16 i = 0; i < nPoints; i++ )
{
GetWinExtMax( ReadPoint(), aBound, nMapMode );
bBoundsDetermined = true;
}
}
SAL_WARN_IF(!bRecordOk, "vcl.wmf", "polyline record claimed more points than the stream can provide");
if (!bRecordOk)
{
pStm->SetError( SVSTREAM_FILEFORMAT_ERROR );
bRet = false;
break;
}
}
break;
......@@ -1507,12 +1526,21 @@ bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pStm )
break;
}
for (sal_uInt16 i = 0; i < nPoints; i++ )
if (nPoints > pStm->remainingSize() / (2 * sizeof(sal_uInt16)))
{
GetWinExtMax( ReadPoint(), aBound, nMapMode );
bBoundsDetermined = true;
bRecordOk = false;
}
else
{
for (sal_uInt16 i = 0; i < nPoints; i++ )
{
GetWinExtMax( ReadPoint(), aBound, nMapMode );
bBoundsDetermined = true;
}
}
SAL_WARN_IF(!bRecordOk, "vcl.wmf", "polypolygon record claimed more points than the stream can provide");
bRecordOk &= pStm->good();
if (!bRecordOk)
......@@ -1526,12 +1554,30 @@ bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pStm )
case W_META_POLYLINE:
{
sal_uInt16 nPoints;
pStm->ReadUInt16( nPoints );
for(sal_uInt16 i = 0; i < nPoints; i++ )
bool bRecordOk = true;
sal_uInt16 nPoints(0);
pStm->ReadUInt16(nPoints);
if (nPoints > pStm->remainingSize() / (2 * sizeof(sal_uInt16)))
{
GetWinExtMax( ReadPoint(), aBound, nMapMode );
bBoundsDetermined = true;
bRecordOk = false;
}
else
{
for (sal_uInt16 i = 0; i < nPoints; ++i)
{
GetWinExtMax( ReadPoint(), aBound, nMapMode );
bBoundsDetermined = true;
}
}
SAL_WARN_IF(!bRecordOk, "vcl.wmf", "polyline record claimed more points than the stream can provide");
if (!bRecordOk)
{
pStm->SetError( SVSTREAM_FILEFORMAT_ERROR );
bRet = false;
break;
}
}
break;
......
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