From 4dfcaf92205b02bf90bd60fd49d6299f6bf00057 Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Fri, 23 May 2014 09:13:53 +0200 Subject: [PATCH] fixed GH #317: Poco::Zip does not support newer Zip file versions. --- Zip/src/ZipLocalFileHeader.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Zip/src/ZipLocalFileHeader.cpp b/Zip/src/ZipLocalFileHeader.cpp index ef7dca368..7e81aec74 100644 --- a/Zip/src/ZipLocalFileHeader.cpp +++ b/Zip/src/ZipLocalFileHeader.cpp @@ -122,9 +122,10 @@ void ZipLocalFileHeader::parse(std::istream& inp, bool assumeHeaderRead) poco_assert (std::memcmp(_rawHeader, HEADER, ZipCommon::HEADER_SIZE) == 0); // 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() <= 2); - poco_assert (ZipUtil::get16BitValue(_rawHeader, COMPR_METHOD_POS) < ZipCommon::CM_UNUSED); + if (!(_rawHeader[VERSION_POS + 1]>= ZipCommon::HS_FAT && _rawHeader[VERSION_POS + 1] < ZipCommon::HS_UNUSED)) + throw Poco::DataFormatException("bad ZIP file header", "invalid version"); + if (ZipUtil::get16BitValue(_rawHeader, COMPR_METHOD_POS) >= ZipCommon::CM_UNUSED) + throw Poco::DataFormatException("bad ZIP file header", "invalid compression method"); parseDateTime(); Poco::UInt16 len = getFileNameLength(); Poco::Buffer buf(len);