diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-10-25 15:05:08 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-10-25 16:56:15 +0100 |
commit | d6ce524de5b05b69fedf8ec43e8bd3fdd01a2cc4 (patch) | |
tree | 22a0b7e3ef9c157acadbe1d79d1d60c2681e756c | |
parent | 6c761698e8866360a09784c26b7784fbae30a191 (diff) |
coverity#1242671 Untrusted value as argument
Change-Id: Ic810391c9ecfef9f28aba34cdc0f85d42ebf656f
-rw-r--r-- | sc/source/filter/starcalc/scflt.cxx | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/sc/source/filter/starcalc/scflt.cxx b/sc/source/filter/starcalc/scflt.cxx index 8bcc346fae9b..39b272a3e389 100644 --- a/sc/source/filter/starcalc/scflt.cxx +++ b/sc/source/filter/starcalc/scflt.cxx @@ -1634,15 +1634,18 @@ void Sc10Import::LoadCol(SCCOL Col, SCTAB Tab) nError = errUnknownFormat; break; } - sal_uInt16 NoteLen; - rStream.ReadUInt16( NoteLen ); - if (NoteLen != 0) + sal_uInt16 nNoteLen(0); + rStream.ReadUInt16(nNoteLen); + size_t nAvailable = rStream.remainingSize(); + if (nNoteLen > nAvailable) + nNoteLen = nAvailable; + if (nNoteLen != 0) { - boost::scoped_array<sal_Char> pNote(new sal_Char[NoteLen+1]); - rStream.Read(pNote.get(), NoteLen); - pNote[NoteLen] = 0; - OUString aNoteText( SC10TOSTRING(pNote.get())); - pNote.reset(); + boost::scoped_array<sal_Char> xNote(new sal_Char[nNoteLen+1]); + nNoteLen = rStream.Read(xNote.get(), nNoteLen); + xNote[nNoteLen] = 0; + OUString aNoteText( SC10TOSTRING(xNote.get())); + xNote.reset(); ScAddress aPos( Col, static_cast<SCROW>(Row), Tab ); ScNoteUtil::CreateNoteFromString( *pDoc, aPos, aNoteText, false, false ); } |