adamhathcock / sharpcompress

SharpCompress is a fully managed C# library to deal with many compression types and formats.
MIT License
2.26k stars 480 forks source link

ZIP64 Streaming Extraction Failure #812

Open pathartl opened 6 months ago

pathartl commented 6 months ago

I've been able to pretty consistently replicate an issue extracting ZIP64's in a stream where it will extract all entries up until a >4GB file and then silently skip over every other entry.

I believe the issue may lie with how the header is read in StreamingZipHeaderFactory. From my limited testing it seems like it's trying to read the header for the next entry 16 bytes past the start of the actual header. This causes ZipHeaderFactory.ReadHeader to return null and stops reading more of the archive.

adamhathcock commented 6 months ago

Definitely seems like a bug in the ZIP64 byte reading. Back to reading the spec. Maybe a bug in Reader vs Archive

Erior commented 3 months ago

Do we have a test file or test file generator for this one?

pathartl commented 3 months ago

Might have fixed in PR #852

Haven't looked into why tests are failing. I was able to create a test archive by zipping a couple of small files, then a large >4GB file, and then another couple of small files. Might need to be in alphabetical order to replicate the original issue correctly. The extraction would skip any files after the first ZIP64 file is extracted because of the improper handling of the header data.