From 7d6c07fa2b48376013b9f8784496d9c1207708f2 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 5 Nov 2014 16:37:27 +0000 Subject: coverity#1242689 Untrusted loop bound Change-Id: Ie226805ef8d430eb3f7b3abaa54ac3af31f72f7b --- basic/source/basmgr/basmgr.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 ); -- cgit