diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-02-02 10:19:55 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-02-02 10:57:20 +0000 |
commit | abc11a4c0cdec0ed2d23a76ffece9840637dcc87 (patch) | |
tree | edc68b3e3f5cf5fdf07e0a30833adb7df6a0634c /vcl | |
parent | b6420535b0bbbaf6db97c2cc1cedd15150d24258 (diff) |
coverity#1242704 Untrusted loop bound
Change-Id: I88c8ff03361aa83b23c811b5d693864360f31f7f
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/filter/wmf/winwmf.cxx | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/vcl/source/filter/wmf/winwmf.cxx b/vcl/source/filter/wmf/winwmf.cxx index 3c8ed8b14ef4..61cba73c5564 100644 --- a/vcl/source/filter/wmf/winwmf.cxx +++ b/vcl/source/filter/wmf/winwmf.cxx @@ -371,6 +371,12 @@ void WMFReader::ReadRecordParams( sal_uInt16 nFunc ) pWMF->ReadUInt16( nPolyCount ); if (nPolyCount && pWMF->good()) { + if (nPolyCount > pWMF->remainingSize() / sizeof(sal_uInt16)) + { + bRecordOk = false; + break; + } + // Number of points of each polygon. Determine total number of points boost::scoped_array<sal_uInt16> xPolygonPointCounts(new sal_uInt16[nPolyCount]); sal_uInt16* pnPoints = xPolygonPointCounts.get(); @@ -403,6 +409,13 @@ void WMFReader::ReadRecordParams( sal_uInt16 nFunc ) for (sal_uInt16 a = 0; a < nPolyCount && pWMF->good(); ++a) { const sal_uInt16 nPointCount(pnPoints[a]); + + if (nPointCount > pWMF->remainingSize() / (2 * sizeof(sal_uInt16))) + { + bRecordOk = false; + break; + } + boost::scoped_array<Point> xPolygonPoints(new Point[nPointCount]); Point* pPtAry = xPolygonPoints.get(); |