diff options
author | Mohammed Abdul Azeem <azeemmysore@gmail.com> | 2017-07-07 00:01:03 +0530 |
---|---|---|
committer | Mohammed Abdul Azeem <azeemmysore@gmail.com> | 2017-07-07 19:58:12 +0200 |
commit | a62507eb405961c27ebf79d6b9bdd7a106d06123 (patch) | |
tree | abfddcffdc922dc34a520c8ab8ef57a7470c1138 /package | |
parent | 11652be4071ef6d1d89b2c397aa1a32476e03bf6 (diff) |
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@collabora.com>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'package')
-rw-r--r-- | package/source/zipapi/XBufferedThreadedStream.cxx | 4 | ||||
-rw-r--r-- | package/source/zipapi/XBufferedThreadedStream.hxx | 2 | ||||
-rw-r--r-- | package/source/zipapi/XUnbufferedStream.cxx | 2 |
3 files changed, 4 insertions, 4 deletions
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( ) |