Skip to content

Unable to unzip zip file created using non-seeking stream #1580

@MrHacky

Description

@MrHacky

Running the following code (in a directory containing the attached input.txt file) results in a CRC error and then throws Poco::IllegalStateException.

#include <Poco/Zip/Decompress.h>
#include <Poco/Zip/Compress.h>
#include <Poco/Delegate.h>

#include <sstream>
#include <iostream>

struct Test {
	void test() {
		std::stringstream output;
		Poco::Zip::Compress zip(output, false);
		zip.addFile("input.txt", "output.txt");
		zip.close();

		std::stringstream input(output.str());
		Poco::Zip::Decompress unzip(input, ".");
		unzip.EError += Poco::Delegate<Test, std::pair<const Poco::Zip::ZipLocalFileHeader, const std::string> >(this, &Test::onDecompressError);
		unzip.decompressAllFiles();
	}

	void onDecompressError(const void* pSender, std::pair<const Poco::Zip::ZipLocalFileHeader, const std::string>& info)
	{
		std::cout << info.second << "\n";
	}
};

int main(int argc, char* argv[])
{
	Test().test();
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions