Skip to content

Commit

Permalink
fixed GH #2661: Poco::Zip::ZipArchive cannot load new tomcat.zip file
Browse files Browse the repository at this point in the history
  • Loading branch information
obiltschnig committed Jul 24, 2019
1 parent 8329020 commit d25b665
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Zip/src/ZipLocalFileHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void ZipLocalFileHeader::parse(std::istream& inp, bool assumeHeaderRead)
std::memcpy(_rawHeader, HEADER, ZipCommon::HEADER_SIZE);
}

// read the rest of the header
// read the rest of the header
inp.read(_rawHeader + ZipCommon::HEADER_SIZE, FULLHEADER_SIZE - ZipCommon::HEADER_SIZE);
poco_assert (_rawHeader[VERSION_POS + 1]>= ZipCommon::HS_FAT && _rawHeader[VERSION_POS + 1] < ZipCommon::HS_UNUSED);
poco_assert (getMajorVersionNumber() <= 4); // Allow for Zip64 version 4.5
Expand All @@ -139,7 +139,7 @@ void ZipLocalFileHeader::parse(std::istream& inp, bool assumeHeaderRead)
inp.read(buf.begin(), len);
_fileName = std::string(buf.begin(), len);
}

if (!searchCRCAndSizesAfterData())
{
_crc32 = getCRCFromHeader();
Expand All @@ -165,8 +165,7 @@ void ZipLocalFileHeader::parse(std::istream& inp, bool assumeHeaderRead)
if (id == ZipCommon::ZIP64_EXTRA_ID)
{
_forceZip64 = true;
poco_assert(size >= 8);
if (getUncompressedSizeFromHeader() == ZipCommon::ZIP64_MAGIC)
if (size >= 8 && getUncompressedSizeFromHeader() == ZipCommon::ZIP64_MAGIC)
{
setUncompressedSize(ZipUtil::get64BitValue(ptr, 0));
size -= 8;
Expand Down

0 comments on commit d25b665

Please sign in to comment.