mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-03 04:38:39 +01:00
fixed GH #2723: Access violation when trying to decompress .zip file with unsupported compression method.
This commit is contained in:
parent
b782d17ced
commit
472684e13c
@ -85,6 +85,8 @@ public:
|
|||||||
|
|
||||||
bool isEncrypted() const;
|
bool isEncrypted() const;
|
||||||
|
|
||||||
|
bool hasSupportedCompressionMethod() const;
|
||||||
|
|
||||||
const Poco::DateTime& lastModifiedAt() const;
|
const Poco::DateTime& lastModifiedAt() const;
|
||||||
|
|
||||||
Poco::UInt32 getCRC() const;
|
Poco::UInt32 getCRC() const;
|
||||||
@ -367,6 +369,13 @@ inline bool ZipLocalFileHeader::isEncrypted() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool ZipLocalFileHeader::hasSupportedCompressionMethod() const
|
||||||
|
{
|
||||||
|
ZipCommon::CompressionMethod method = getCompressionMethod();
|
||||||
|
return method == ZipCommon::CM_DEFLATE || method == ZipCommon::CM_STORE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void ZipLocalFileHeader::setEncryption(bool val)
|
inline void ZipLocalFileHeader::setEncryption(bool val)
|
||||||
{
|
{
|
||||||
if (val)
|
if (val)
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "Poco/StreamCopier.h"
|
#include "Poco/StreamCopier.h"
|
||||||
#include "Poco/Delegate.h"
|
#include "Poco/Delegate.h"
|
||||||
#include "Poco/FileStream.h"
|
#include "Poco/FileStream.h"
|
||||||
|
#include "Poco/Format.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
@ -107,7 +108,14 @@ bool Decompress::handleZipEntry(std::istream& zipStream, const ZipLocalFileHeade
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!ZipCommon::isValidPath(fileName))
|
if (!ZipCommon::isValidPath(fileName))
|
||||||
|
{
|
||||||
throw ZipException("Illegal entry name", fileName);
|
throw ZipException("Illegal entry name", fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hdr.hasSupportedCompressionMethod())
|
||||||
|
{
|
||||||
|
throw ZipException(Poco::format("Unsupported compression method (%d)", static_cast<int>(hdr.getCompressionMethod())), fileName);
|
||||||
|
}
|
||||||
|
|
||||||
Poco::Path file(fileName);
|
Poco::Path file(fileName);
|
||||||
file.makeFile();
|
file.makeFile();
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
#include "Poco/InflatingStream.h"
|
#include "Poco/InflatingStream.h"
|
||||||
#include "Poco/DeflatingStream.h"
|
#include "Poco/DeflatingStream.h"
|
||||||
|
#include "Poco/Format.h"
|
||||||
#if defined(POCO_UNBUNDLED)
|
#if defined(POCO_UNBUNDLED)
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
#else
|
#else
|
||||||
@ -80,7 +81,6 @@ ZipStreamBuf::ZipStreamBuf(std::istream& istr, const ZipLocalFileHeader& fileEnt
|
|||||||
_ptrBuf = new PartialInputStream(istr, start, end, reposition);
|
_ptrBuf = new PartialInputStream(istr, start, end, reposition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else throw Poco::NotImplementedException("Unsupported compression method");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -299,6 +299,10 @@ ZipStreamBuf* ZipIOS::rdbuf()
|
|||||||
|
|
||||||
ZipInputStream::ZipInputStream(std::istream& istr, const ZipLocalFileHeader& fileEntry, bool reposition): ZipIOS(istr, fileEntry, reposition), std::istream(&_buf)
|
ZipInputStream::ZipInputStream(std::istream& istr, const ZipLocalFileHeader& fileEntry, bool reposition): ZipIOS(istr, fileEntry, reposition), std::istream(&_buf)
|
||||||
{
|
{
|
||||||
|
if (!fileEntry.hasSupportedCompressionMethod())
|
||||||
|
{
|
||||||
|
throw ZipException(Poco::format("Unsupported compression method (%d)", static_cast<int>(fileEntry.getCompressionMethod())), fileEntry.getFileName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user