[Libreoffice-commits] core.git: package/source
Mohammed Abdul Azeem
azeemmysore at gmail.com
Fri Jul 7 17:58:39 UTC 2017
package/source/zipapi/XBufferedThreadedStream.cxx | 4 ++--
package/source/zipapi/XBufferedThreadedStream.hxx | 2 +-
package/source/zipapi/XUnbufferedStream.cxx | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
New commits:
commit a62507eb405961c27ebf79d6b9bdd7a106d06123
Author: Mohammed Abdul Azeem <azeemmysore at gmail.com>
Date: Fri Jul 7 00:01:03 2017 +0530
tdf#108821 - fix for overflow of variables on opening huge files
This should fix the issue, as well as restrict available
to return only non-negative values.
Change-Id: I198e226e945b9bd79dec32b1686c20e2a8dfaf3e
Reviewed-on: https://gerrit.libreoffice.org/39665
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/package/source/zipapi/XBufferedThreadedStream.cxx b/package/source/zipapi/XBufferedThreadedStream.cxx
index 87b7349cccba..c7fd3dbacd36 100644
--- a/package/source/zipapi/XBufferedThreadedStream.cxx
+++ b/package/source/zipapi/XBufferedThreadedStream.cxx
@@ -145,7 +145,7 @@ sal_Int32 SAL_CALL XBufferedThreadedStream::readBytes( Sequence< sal_Int8 >& rDa
if( !hasBytes() )
return 0;
- const sal_Int32 nAvailableSize = std::min<sal_Int32>( nBytesToRead, remainingSize() );
+ const sal_Int32 nAvailableSize = static_cast< sal_Int32 > ( std::min< sal_Int64 >( nBytesToRead, remainingSize() ) );
rData.realloc( nAvailableSize );
sal_Int32 i = 0, nPendingBytes = nAvailableSize;
@@ -188,7 +188,7 @@ sal_Int32 SAL_CALL XBufferedThreadedStream::available()
if( !hasBytes() )
return 0;
- return remainingSize();
+ return static_cast< sal_Int32 > ( std::min< sal_Int64 >( SAL_MAX_INT32, remainingSize() ) );
}
void SAL_CALL XBufferedThreadedStream::closeInput()
diff --git a/package/source/zipapi/XBufferedThreadedStream.hxx b/package/source/zipapi/XBufferedThreadedStream.hxx
index 9ba908e01f5e..c28bb049de16 100644
--- a/package/source/zipapi/XBufferedThreadedStream.hxx
+++ b/package/source/zipapi/XBufferedThreadedStream.hxx
@@ -44,7 +44,7 @@ private:
static const size_t nBufferSize = 32 * 1024;
const Buffer& getNextBlock();
- size_t remainingSize() const { return mnStreamSize - mnPos; }
+ sal_Int64 remainingSize() const { return mnStreamSize - mnPos; }
bool hasBytes() const { return mnPos < mnStreamSize; }
bool canProduce() const
diff --git a/package/source/zipapi/XUnbufferedStream.cxx b/package/source/zipapi/XUnbufferedStream.cxx
index e82e720795d3..d1f65b29b7aa 100644
--- a/package/source/zipapi/XUnbufferedStream.cxx
+++ b/package/source/zipapi/XUnbufferedStream.cxx
@@ -310,7 +310,7 @@ void SAL_CALL XUnbufferedStream::skipBytes( sal_Int32 nBytesToSkip )
sal_Int32 SAL_CALL XUnbufferedStream::available( )
{
//available size must include the prepended header in case of wrapped raw stream
- return static_cast < sal_Int32 > ( mnZipSize + mnHeaderToRead - mnMyCurrent );
+ return static_cast< sal_Int32 > ( std::min< sal_Int64 >( SAL_MAX_INT32, (mnZipSize + mnHeaderToRead - mnMyCurrent) ) );
}
void SAL_CALL XUnbufferedStream::closeInput( )
More information about the Libreoffice-commits
mailing list