Skip to content

Commit 4dfcaf9

Browse files
committed
fixed GH pocoproject#317: Poco::Zip does not support newer Zip file versions.
1 parent 2813f99 commit 4dfcaf9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Zip/src/ZipLocalFileHeader.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,10 @@ void ZipLocalFileHeader::parse(std::istream& inp, bool assumeHeaderRead)
122122
poco_assert (std::memcmp(_rawHeader, HEADER, ZipCommon::HEADER_SIZE) == 0);
123123
// read the rest of the header
124124
inp.read(_rawHeader + ZipCommon::HEADER_SIZE, FULLHEADER_SIZE - ZipCommon::HEADER_SIZE);
125-
poco_assert (_rawHeader[VERSION_POS + 1]>= ZipCommon::HS_FAT && _rawHeader[VERSION_POS + 1] < ZipCommon::HS_UNUSED);
126-
poco_assert (getMajorVersionNumber() <= 2);
127-
poco_assert (ZipUtil::get16BitValue(_rawHeader, COMPR_METHOD_POS) < ZipCommon::CM_UNUSED);
125+
if (!(_rawHeader[VERSION_POS + 1]>= ZipCommon::HS_FAT && _rawHeader[VERSION_POS + 1] < ZipCommon::HS_UNUSED))
126+
throw Poco::DataFormatException("bad ZIP file header", "invalid version");
127+
if (ZipUtil::get16BitValue(_rawHeader, COMPR_METHOD_POS) >= ZipCommon::CM_UNUSED)
128+
throw Poco::DataFormatException("bad ZIP file header", "invalid compression method");
128129
parseDateTime();
129130
Poco::UInt16 len = getFileNameLength();
130131
Poco::Buffer<char> buf(len);

0 commit comments

Comments
 (0)