summaryrefslogtreecommitdiff
path: root/package/source/zipapi
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2009-07-30 10:52:48 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2009-07-30 10:52:48 +0000
commitde05a247d864fc65ed94bdec30602eae1d0bb430 (patch)
tree7fb8ef76351df0b3f46a1189322d828519dabd8b /package/source/zipapi
parent6c0eee7ed36e6c466c79a9ba195bcce64311103c (diff)
CWS-TOOLING: integrate CWS fwk114
2009-07-08 Mikhail Voytenko #i102448# fix typo 2009-07-08 Mikhail Voytenko #i102448# detect the document of new format correctly 2009-07-03 Mikhail Voytenko #i101418# adjust header 2009-07-02 Mikhail Voytenko #i103001# Integrate the patch 2009-07-01 Mikhail Voytenko rebase to DEV300_m51 2009-06-25 Mikhail Voytenko #i71512# integrate the patch 2009-06-19 Mikhail Voytenko #i102931# check whether the file was changed even in case of system file locking 2009-06-10 Mikhail Voytenko #i102448# allow to turn the office update dialog off 2009-06-10 Mikhail Voytenko #i102448# allow to turn the office update dialog off 2009-06-09 Mikhail Voytenko #i96091# the disposed frame should throw DisposedException 2009-06-09 Mikhail Voytenko #i100835# commit the patch 2009-05-26 Mikhail Voytenko #i89514# integrate the patch 2009-05-26 Mikhail Voytenko #i30373# integrate the patch 2009-05-26 Mikhail Voytenko #i101418# fix the error handling
Diffstat (limited to 'package/source/zipapi')
-rw-r--r--package/source/zipapi/Inflater.cxx27
-rw-r--r--package/source/zipapi/XUnbufferedStream.cxx6
2 files changed, 24 insertions, 9 deletions
diff --git a/package/source/zipapi/Inflater.cxx b/package/source/zipapi/Inflater.cxx
index 178767b06cdc..62228bf22c8e 100644
--- a/package/source/zipapi/Inflater.cxx
+++ b/package/source/zipapi/Inflater.cxx
@@ -45,12 +45,12 @@ using namespace com::sun::star::uno;
/** Provides general purpose decompression using the ZLIB library */
Inflater::Inflater(sal_Bool bNoWrap)
-: bFinish(sal_False),
- bFinished(sal_False),
+: bFinished(sal_False),
bSetParams(sal_False),
bNeedDict(sal_False),
nOffset(0),
nLength(0),
+ nLastInflateError(0),
pStream(NULL)
{
pStream = new z_stream;
@@ -120,16 +120,23 @@ void SAL_CALL Inflater::end( )
sal_Int32 Inflater::doInflateBytes (Sequence < sal_Int8 > &rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength)
{
- sal_Int32 nResult;
+ if ( !pStream )
+ {
+ nLastInflateError = Z_STREAM_ERROR;
+ return 0;
+ }
+
+ nLastInflateError = 0;
+
pStream->next_in = ( unsigned char* ) ( sInBuffer.getConstArray() + nOffset );
pStream->avail_in = nLength;
pStream->next_out = reinterpret_cast < unsigned char* > ( rBuffer.getArray() + nNewOffset );
pStream->avail_out = nNewLength;
#ifdef SYSTEM_ZLIB
- nResult = ::inflate(pStream, bFinish ? Z_SYNC_FLUSH : Z_PARTIAL_FLUSH);
+ sal_Int32 nResult = ::inflate(pStream, Z_PARTIAL_FLUSH);
#else
- nResult = ::z_inflate(pStream, bFinish ? Z_SYNC_FLUSH : Z_PARTIAL_FLUSH);
+ sal_Int32 nResult = ::z_inflate(pStream, Z_PARTIAL_FLUSH);
#endif
switch (nResult)
@@ -140,15 +147,19 @@ sal_Int32 Inflater::doInflateBytes (Sequence < sal_Int8 > &rBuffer, sal_Int32 n
nOffset += nLength - pStream->avail_in;
nLength = pStream->avail_in;
return nNewLength - pStream->avail_out;
+
case Z_NEED_DICT:
bNeedDict = sal_True;
nOffset += nLength - pStream->avail_in;
nLength = pStream->avail_in;
- case Z_BUF_ERROR:
- return 0;
- case Z_DATA_ERROR:
return 0;
+
+ default:
+ // it is no error, if there is no input or no output
+ if ( nLength && nNewLength )
+ nLastInflateError = nResult;
}
+
return 0;
}
diff --git a/package/source/zipapi/XUnbufferedStream.cxx b/package/source/zipapi/XUnbufferedStream.cxx
index cb99c085bc28..1eba064a2165 100644
--- a/package/source/zipapi/XUnbufferedStream.cxx
+++ b/package/source/zipapi/XUnbufferedStream.cxx
@@ -230,7 +230,7 @@ sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sa
OUString( RTL_CONSTASCII_USTRINGPARAM( "Should not be possible to read more then requested!" ) ),
Reference< XInterface >() );
- if ( maInflater.finished() )
+ if ( maInflater.finished() || maInflater.getLastInflateError() )
throw ZipIOException( OUString( RTL_CONSTASCII_USTRINGPARAM( "The stream seems to be broken!" ) ),
Reference< XInterface >() );
@@ -244,6 +244,10 @@ sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sa
mxZipSeek->seek ( mnZipCurrent );
sal_Int32 nToRead = std::min ( nDiff, std::max ( nRequestedBytes, static_cast< sal_Int32 >( 8192 ) ) );
sal_Int32 nZipRead = mxZipStream->readBytes ( maCompBuffer, nToRead );
+ if ( nZipRead < nToRead )
+ throw ZipIOException( OUString( RTL_CONSTASCII_USTRINGPARAM( "No expected data!" ) ),
+ Reference< XInterface >() );
+
mnZipCurrent += nZipRead;
// maCompBuffer now has the data, check if we need to decrypt
// before passing to the Inflater