summaryrefslogtreecommitdiffstats
path: root/package/source/zipapi/XUnbufferedStream.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'package/source/zipapi/XUnbufferedStream.cxx')
-rw-r--r--package/source/zipapi/XUnbufferedStream.cxx59
1 files changed, 29 insertions, 30 deletions
diff --git a/package/source/zipapi/XUnbufferedStream.cxx b/package/source/zipapi/XUnbufferedStream.cxx
index d300abefcd97..0292217d966f 100644
--- a/package/source/zipapi/XUnbufferedStream.cxx
+++ b/package/source/zipapi/XUnbufferedStream.cxx
@@ -233,45 +233,44 @@ sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sa
throw ZipIOException("Dictionaries are not supported!" );
sal_Int32 nDiff = static_cast< sal_Int32 >( mnZipEnd - mnZipCurrent );
- if ( nDiff > 0 )
+ if ( nDiff <= 0 )
{
- mxZipSeek->seek ( mnZipCurrent );
+ throw ZipIOException("The stream seems to be broken!" );
+ }
- sal_Int32 nToRead = std::max( nRequestedBytes, static_cast< sal_Int32 >( 8192 ) );
- if ( mnBlockSize > 1 )
- nToRead = nToRead + mnBlockSize - nToRead % mnBlockSize;
- nToRead = std::min( nDiff, nToRead );
+ mxZipSeek->seek ( mnZipCurrent );
- sal_Int32 nZipRead = mxZipStream->readBytes( maCompBuffer, nToRead );
- if ( nZipRead < nToRead )
- throw ZipIOException("No expected data!" );
+ sal_Int32 nToRead = std::max( nRequestedBytes, static_cast< sal_Int32 >( 8192 ) );
+ if ( mnBlockSize > 1 )
+ nToRead = nToRead + mnBlockSize - nToRead % mnBlockSize;
+ nToRead = std::min( nDiff, nToRead );
- mnZipCurrent += nZipRead;
- // maCompBuffer now has the data, check if we need to decrypt
- // before passing to the Inflater
- if ( m_xCipherContext.is() )
- {
- if ( mbCheckCRC )
- maCRC.update( maCompBuffer );
+ sal_Int32 nZipRead = mxZipStream->readBytes( maCompBuffer, nToRead );
+ if ( nZipRead < nToRead )
+ throw ZipIOException("No expected data!" );
- maCompBuffer = m_xCipherContext->convertWithCipherContext( maCompBuffer );
- if ( mnZipCurrent == mnZipEnd )
+ mnZipCurrent += nZipRead;
+ // maCompBuffer now has the data, check if we need to decrypt
+ // before passing to the Inflater
+ if ( m_xCipherContext.is() )
+ {
+ if ( mbCheckCRC )
+ maCRC.update( maCompBuffer );
+
+ maCompBuffer = m_xCipherContext->convertWithCipherContext( maCompBuffer );
+ if ( mnZipCurrent == mnZipEnd )
+ {
+ uno::Sequence< sal_Int8 > aSuffix = m_xCipherContext->finalizeCipherContextAndDispose();
+ if ( aSuffix.getLength() )
{
- uno::Sequence< sal_Int8 > aSuffix = m_xCipherContext->finalizeCipherContextAndDispose();
- if ( aSuffix.getLength() )
- {
- sal_Int32 nOldLen = maCompBuffer.getLength();
- maCompBuffer.realloc( nOldLen + aSuffix.getLength() );
- memcpy( maCompBuffer.getArray() + nOldLen, aSuffix.getConstArray(), aSuffix.getLength() );
- }
+ sal_Int32 nOldLen = maCompBuffer.getLength();
+ maCompBuffer.realloc( nOldLen + aSuffix.getLength() );
+ memcpy( maCompBuffer.getArray() + nOldLen, aSuffix.getConstArray(), aSuffix.getLength() );
}
}
- maInflater.setInput ( maCompBuffer );
- }
- else
- {
- throw ZipIOException("The stream seems to be broken!" );
}
+ maInflater.setInput ( maCompBuffer );
+
}
}