diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-11-05 16:16:14 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-11-05 21:03:24 +0000 |
commit | 5b0c95d81eb4c311d80aabaa1cfe16bc1b426111 (patch) | |
tree | d720ed9b1898be260071f966c5d3e905630b847a /basic | |
parent | 4a83b67e3c3dc8bceb6602ce155f2463f72f4855 (diff) |
coverity#1242794 Untrusted loop bound
Change-Id: I902a5bf989a8f385994a2f927cce4975b18f06d2
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/classes/sb.cxx | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 5a88c3d3450a..8c2155e610b4 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -1895,10 +1895,18 @@ bool StarBASIC::LoadData( SvStream& r, sal_uInt16 nVer ) } ppDeleteTab.reset(); - sal_uInt16 nMod; + sal_uInt16 nMod(0); pModules->Clear(); r.ReadUInt16( nMod ); - for( sal_uInt16 i = 0; i < nMod; i++ ) + const size_t nMinSbxSize(14); + const size_t nMaxPossibleEntries = r.remainingSize() / nMinSbxSize; + if (nMod > nMaxPossibleEntries) + { + nMod = nMaxPossibleEntries; + SAL_WARN("basic", "Parsing error: " << nMaxPossibleEntries << + " max possible entries, but " << nMod << " claimed, truncating"); + } + for (sal_uInt16 i = 0; i < nMod; ++i) { SbxBase* pBase = SbxBase::Load( r ); SbModule* pMod = dynamic_cast<SbModule*>(pBase); |