diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-01-26 11:04:35 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-01-26 12:14:43 +0000 |
commit | 83de961e0d5fcdcf2ca096736a03887e1cdf2ed8 (patch) | |
tree | f8d9a4a3aa0e9143cb88ca1b1b83e5c53576e23c /tools | |
parent | 381ea04355deae554aeb84f373f012e28518a5f2 (diff) |
coverity#1244945 Untrusted value as argument
Change-Id: Ic969ea78a53d0a67591dd476bc01fbdce18c7eab
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/generic/poly2.cxx | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/source/generic/poly2.cxx b/tools/source/generic/poly2.cxx index f6b6f3efc2ce..a800f1ff5892 100644 --- a/tools/source/generic/poly2.cxx +++ b/tools/source/generic/poly2.cxx @@ -582,7 +582,7 @@ SvStream& ReadPolyPolygon( SvStream& rIStream, tools::PolyPolygon& rPolyPoly ) const size_t nMaxRecords = rIStream.remainingSize() / nMinRecordSize; if (nPolyCount > nMaxRecords) { - SAL_WARN("vcl.gdi", "Parsing error: " << nMaxRecords << + SAL_WARN("tools", "Parsing error: " << nMaxRecords << " max possible entries, but " << nPolyCount << " claimed, truncating"); nPolyCount = nMaxRecords; } @@ -636,6 +636,15 @@ void PolyPolygon::Read( SvStream& rIStream ) // Read number of polygons rIStream.ReadUInt16( nPolyCount ); + const size_t nMinRecordSize = sizeof(sal_uInt16); + const size_t nMaxRecords = rIStream.remainingSize() / nMinRecordSize; + if (nPolyCount > nMaxRecords) + { + SAL_WARN("tools", "Parsing error: " << nMaxRecords << + " max possible entries, but " << nPolyCount << " claimed, truncating"); + nPolyCount = nMaxRecords; + } + if( nPolyCount ) { if ( mpImplPolyPolygon->mnRefCount > 1 ) |