diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-11-17 17:03:15 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-11-17 20:25:48 +0000 |
commit | 96b524cdd639b57c875eada551e267654f2a83fc (patch) | |
tree | acb9e442f7a7c8885201a3c737569e096096ecbf /sc/source/filter/excel | |
parent | 5d0da4db5a8c7a76f83c4db60e4577bf2202ed9f (diff) |
coverity#1242891 Untrusted loop bound
Change-Id: I5859cef0fa6b9c49225c5d7b073bcbc521734854
Diffstat (limited to 'sc/source/filter/excel')
-rw-r--r-- | sc/source/filter/excel/xistyle.cxx | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx index 7349a8ea8b8a..446b283969bf 100644 --- a/sc/source/filter/excel/xistyle.cxx +++ b/sc/source/filter/excel/xistyle.cxx @@ -150,8 +150,15 @@ void XclImpPalette::ReadPalette( XclImpStream& rStrm ) { sal_uInt16 nCount; rStrm >> nCount; - OSL_ENSURE( rStrm.GetRecLeft() == static_cast< sal_Size >( 4 * nCount ), - "XclImpPalette::ReadPalette - size mismatch" ); + + const size_t nMinRecordSize = 4; + const size_t nMaxRecords = rStrm.GetRecLeft() / nMinRecordSize; + if (nCount > nMaxRecords) + { + SAL_WARN("sc", "Parsing error: " << nMaxRecords << + " max possible entries, but " << nCount << " claimed, truncating"); + nCount = nMaxRecords; + } maColorTable.resize( nCount ); Color aColor; @@ -164,7 +171,6 @@ void XclImpPalette::ReadPalette( XclImpStream& rStrm ) } // FONT record - font information ============================================= - XclImpFont::XclImpFont( const XclImpRoot& rRoot ) : XclImpRoot( rRoot ), mbHasCharSet( false ), |