diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-11-05 16:37:27 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-11-05 21:03:25 +0000 |
commit | 7d6c07fa2b48376013b9f8784496d9c1207708f2 (patch) | |
tree | 1f2364150dbd9cda414d865fbd0be5aa171f51a1 /basic | |
parent | 1409c0bd884ffc2c9fb656fe61ac62d759bc436d (diff) |
coverity#1242689 Untrusted loop bound
Change-Id: Ie226805ef8d430eb3f7b3abaa54ac3af31f72f7b
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/basmgr/basmgr.cxx | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index 15056527baca..b0f05216a4a0 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -860,7 +860,15 @@ void BasicManager::LoadBasicManager( SotStorage& rStorage, const OUString& rBase DBG_ASSERT( false, "BasicManager-Stream defect!" ); return; } - for ( sal_uInt16 nL = 0; nL < nLibs; nL++ ) + const size_t nMinBasicLibSize(8); + const size_t nMaxPossibleLibs = xManagerStream->remainingSize() / nMinBasicLibSize; + if (nLibs > nMaxPossibleLibs) + { + SAL_WARN("basic", "Parsing error: " << nMaxPossibleLibs << + " max possible entries, but " << nLibs << " claimed, truncating"); + nLibs = nMaxPossibleLibs; + } + for (sal_uInt16 nL = 0; nL < nLibs; ++nL) { BasicLibInfo* pInfo = BasicLibInfo::Create( *xManagerStream ); |