[Libreoffice-commits] core.git: sc/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Mon Apr 5 13:27:21 UTC 2021
sc/source/filter/excel/xistream.cxx | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
New commits:
commit b356facc76ae31f82d2d0a68af152680cc003929
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Mar 31 09:54:15 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Apr 5 15:26:42 2021 +0200
cid#1474256 silence Untrusted loop bound
Change-Id: Ibcd59331f16f348209e9b043694cd721a94210c4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113575
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sc/source/filter/excel/xistream.cxx b/sc/source/filter/excel/xistream.cxx
index e1126aaf2950..df5500cc376d 100644
--- a/sc/source/filter/excel/xistream.cxx
+++ b/sc/source/filter/excel/xistream.cxx
@@ -746,19 +746,21 @@ std::size_t XclImpStream::Read( void* pData, std::size_t nBytes )
std::size_t XclImpStream::CopyToStream( SvStream& rOutStrm, std::size_t nBytes )
{
std::size_t nRet = 0;
- if( mbValid && (nBytes > 0) )
+ if (mbValid && nBytes)
{
const std::size_t nMaxBuffer = 4096;
- std::unique_ptr<sal_uInt8[]> pnBuffer(new sal_uInt8[ ::std::min( nBytes, nMaxBuffer ) ]);
+ std::vector<sal_uInt8> aBuffer(o3tl::sanitizing_min(nBytes, nMaxBuffer));
std::size_t nBytesLeft = nBytes;
- while( mbValid && (nBytesLeft > 0) )
+ while (mbValid)
{
- std::size_t nReadSize = ::std::min( nBytesLeft, nMaxBuffer );
- nRet += Read( pnBuffer.get(), nReadSize );
+ if (!nBytesLeft)
+ break;
+ std::size_t nReadSize = o3tl::sanitizing_min(nBytesLeft, nMaxBuffer);
+ nRet += Read(aBuffer.data(), nReadSize);
// writing more bytes than read results in invalid memory access
SAL_WARN_IF(nRet != nReadSize, "sc", "read less bytes than requested");
- rOutStrm.WriteBytes(pnBuffer.get(), nReadSize);
+ rOutStrm.WriteBytes(aBuffer.data(), nReadSize);
nBytesLeft -= nReadSize;
}
}
More information about the Libreoffice-commits
mailing list