#84734# Restrict the number of bytes read from a compressed stream when checking for zip file header to a 32k LZ77 window
This commit is contained in:
parent
73fa79cb75
commit
6e0caeee8a
4 changed files with 24 additions and 25 deletions
|
@ -2,9 +2,9 @@
|
|||
*
|
||||
* $RCSfile: Inflater.hxx,v $
|
||||
*
|
||||
* $Revision: 1.4 $
|
||||
* $Revision: 1.5 $
|
||||
*
|
||||
* last change: $Author: mtg $ $Date: 2000-12-19 21:55:35 $
|
||||
* last change: $Author: mtg $ $Date: 2001-03-07 19:24:14 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
|
@ -113,6 +113,8 @@ public:
|
|||
throw(::com::sun::star::uno::RuntimeException);
|
||||
virtual sal_Bool SAL_CALL needsDictionary( )
|
||||
throw(::com::sun::star::uno::RuntimeException);
|
||||
virtual void SAL_CALL finish( )
|
||||
throw(::com::sun::star::uno::RuntimeException);
|
||||
virtual sal_Bool SAL_CALL finished( )
|
||||
throw(::com::sun::star::uno::RuntimeException);
|
||||
virtual sal_Int32 SAL_CALL doInflateSegment( ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
*
|
||||
* $RCSfile: ZipFile.hxx,v $
|
||||
*
|
||||
* $Revision: 1.8 $
|
||||
* $Revision: 1.9 $
|
||||
*
|
||||
* last change: $Author: mtg $ $Date: 2000-12-19 21:55:35 $
|
||||
* last change: $Author: mtg $ $Date: 2001-03-07 19:24:14 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
|
@ -114,10 +114,9 @@ private:
|
|||
::rtl::OUString sComment; /* zip file comment */
|
||||
EntryHash aEntries;
|
||||
ByteGrabber aGrabber;
|
||||
Inflater aInflater;
|
||||
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xStream;
|
||||
public:
|
||||
ZipFile( com::sun::star::uno::Reference < com::sun::star::io::XInputStream > &xInput)
|
||||
throw(::com::sun::star::io::IOException, com::sun::star::package::ZipException, com::sun::star::uno::RuntimeException);
|
||||
ZipFile( com::sun::star::uno::Reference < com::sun::star::io::XInputStream > &xInput, sal_Bool bInitialise)
|
||||
throw(::com::sun::star::io::IOException, com::sun::star::package::ZipException, com::sun::star::uno::RuntimeException);
|
||||
void updateFromManList(std::vector < ManifestEntry * > &rManList);
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
*
|
||||
* $RCSfile: Inflater.cxx,v $
|
||||
*
|
||||
* $Revision: 1.5 $
|
||||
* $Revision: 1.6 $
|
||||
*
|
||||
* last change: $Author: mtg $ $Date: 2000-12-19 21:55:39 $
|
||||
* last change: $Author: mtg $ $Date: 2001-03-07 19:24:15 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
|
@ -178,6 +178,11 @@ sal_Bool SAL_CALL Inflater::needsDictionary( )
|
|||
return bNeedDict;
|
||||
}
|
||||
|
||||
void SAL_CALL Inflater::finish( )
|
||||
throw(com::sun::star::uno::RuntimeException)
|
||||
{
|
||||
bFinish = sal_True;
|
||||
}
|
||||
sal_Bool SAL_CALL Inflater::finished( )
|
||||
throw(com::sun::star::uno::RuntimeException)
|
||||
{
|
||||
|
@ -222,8 +227,7 @@ void SAL_CALL Inflater::reset( )
|
|||
throw(com::sun::star::uno::RuntimeException)
|
||||
{
|
||||
z_inflateReset(pStream);
|
||||
bNeedDict = sal_False;
|
||||
bFinished = sal_False;
|
||||
bFinish = bNeedDict = bFinished = sal_False;
|
||||
nOffset = nLength = 0;
|
||||
}
|
||||
|
||||
|
@ -246,7 +250,7 @@ sal_Int32 Inflater::doInflateBytes (com::sun::star::uno::Sequence < sal_Int8 >
|
|||
pStream->next_out = (unsigned char*) rBuffer.getArray() + nNewOffset;
|
||||
pStream->avail_out = nNewLength;
|
||||
|
||||
nResult = ::z_inflate(pStream, Z_PARTIAL_FLUSH);
|
||||
nResult = ::z_inflate(pStream, bFinish ? Z_SYNC_FLUSH : Z_PARTIAL_FLUSH);
|
||||
|
||||
switch (nResult)
|
||||
{
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
*
|
||||
* $RCSfile: ZipFile.cxx,v $
|
||||
*
|
||||
* $Revision: 1.16 $
|
||||
* $Revision: 1.17 $
|
||||
*
|
||||
* last change: $Author: mtg $ $Date: 2001-03-07 16:09:44 $
|
||||
* last change: $Author: mtg $ $Date: 2001-03-07 19:24:15 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
|
@ -69,17 +69,11 @@ using namespace com::sun::star::package::ZipConstants;
|
|||
|
||||
/** This class is used to read entries from a zip file
|
||||
*/
|
||||
ZipFile::ZipFile (uno::Reference < io::XInputStream > &xInput)
|
||||
throw(io::IOException, package::ZipException, uno::RuntimeException)
|
||||
: xStream(xInput)
|
||||
, aGrabber(xInput)
|
||||
{
|
||||
readCEN();
|
||||
}
|
||||
ZipFile::ZipFile( uno::Reference < io::XInputStream > &xInput, sal_Bool bInitialise)
|
||||
throw(io::IOException, package::ZipException, uno::RuntimeException)
|
||||
: xStream(xInput)
|
||||
, aGrabber(xInput)
|
||||
, aInflater (sal_True)
|
||||
{
|
||||
if (bInitialise)
|
||||
readCEN();
|
||||
|
@ -209,19 +203,19 @@ sal_uInt32 SAL_CALL ZipFile::getHeader(const package::ZipEntry& rEntry)
|
|||
}
|
||||
else if (rEntry.nMethod == DEFLATED)
|
||||
{
|
||||
/*
|
||||
uno::Reference < io::XInputStream > xEntryStream = getInputStream (rEntry);
|
||||
if (xEntryStream->readBytes(aSequence, 4) < 4)
|
||||
return 0;
|
||||
/*
|
||||
Inflater aInflater ( sal_True );
|
||||
sal_Int32 nSize = rEntry.nCompressedSize < 50 ? rEntry.nCompressedSize : 50;
|
||||
*/
|
||||
sal_Int32 nSize = rEntry.nCompressedSize < 32768 ? rEntry.nCompressedSize : 32768;
|
||||
uno::Sequence < sal_Int8 > aCompSeq (nSize );
|
||||
if (xStream->readBytes(aCompSeq, nSize) < nSize)
|
||||
return 0;
|
||||
aInflater.finish();
|
||||
aInflater.setInput(aCompSeq);
|
||||
aInflater.doInflate(aSequence);
|
||||
aInflater.end();
|
||||
*/
|
||||
aInflater.reset();
|
||||
}
|
||||
return (static_cast < sal_uInt32 >
|
||||
(static_cast < sal_uInt8> (aSequence[0]& 0xFF)
|
||||
|
|
Loading…
Reference in a new issue