I am using DotNetZip to extract zip files that come from an extenal (not trustworthy) source. My problem is that the zip file itself can be a couple of kilobytes, but the unzipped content can become petabytes. How to see the uncompressed size before unpacking? Is there a reliable way to see this and prevent a OutOfMemoryException?
As suggested below it can be done with ionic zip:
using (ZipFile zip = ZipFile.Read(zipFile))
{
// Option 2 - will need to sift through the mass of info
info = zip.Info;
foreach (ZipEntry e in zip)
{
long uncompressedsize = e.UncompressedSize;
// Option 1
totaluncompressedsize += uncompressedsize;
}
}
But the question remains: Is the UncompressedSize
completely reliable? Can someone change this information to make it appear as a small uncompressed size?