Kaydet (Commit) 8fe8c2e3 authored tarafından Caolán McNamara's avatar Caolán McNamara

coverity#1242630 Untrusted loop bound

Change-Id: I985f47d6e5f5aa86099b86ad4666b194f4b25b83
üst 8e6c22d7
...@@ -100,10 +100,24 @@ SvStream& SvxMacroTableDtor::Read( SvStream& rStrm, sal_uInt16 nVersion ) ...@@ -100,10 +100,24 @@ SvStream& SvxMacroTableDtor::Read( SvStream& rStrm, sal_uInt16 nVersion )
{ {
if( SVX_MACROTBL_VERSION40 <= nVersion ) if( SVX_MACROTBL_VERSION40 <= nVersion )
rStrm.ReadUInt16( nVersion ); rStrm.ReadUInt16( nVersion );
short nMacro;
rStrm.ReadInt16( nMacro );
for( short i = 0; i < nMacro; ++i ) short nMacro(0);
rStrm.ReadInt16(nMacro);
const size_t nMinStringSize = rStrm.GetStreamCharSet() == RTL_TEXTENCODING_UNICODE ? 4 : 2;
size_t nMinRecordSize = 2 + 2*nMinStringSize;
if( SVX_MACROTBL_VERSION40 <= nVersion )
nMinRecordSize+=2;
const size_t nMaxRecords = rStrm.remainingSize() / nMinRecordSize;
if (nMacro > 0 && static_cast<size_t>(nMacro) > nMaxRecords)
{
SAL_WARN("editeng", "Parsing error: " << nMaxRecords <<
" max possible entries, but " << nMacro<< " claimed, truncating");
nMacro = nMaxRecords;
}
for (short i = 0; i < nMacro; ++i)
{ {
sal_uInt16 nCurKey, eType = STARBASIC; sal_uInt16 nCurKey, eType = STARBASIC;
OUString aLibName, aMacName; OUString aLibName, aMacName;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment