ZIP ReaderFactory IEntry properties are not assigned #580

Open
opened 2026-01-29 22:14:07 +00:00 by claunia · 4 comments
Owner

Originally created by @jbrockerville on GitHub (Jul 31, 2023).

I have ZIP files created with a unknown app. I am accessing the IEntry entries via the ReaderFactory (a la USAGE.md). The entries contain their key, but all the other properties (e.g., CRC, uncompressed size, compressed size, various date-times, etc.) are not assigned (set to zero or null).

A couple interesting observations:

  • Despite the unassigned IEntry properties, opening the entry stream and copying it works fine.
  • If I use ArchiveFactory to access these ZIP files, their IEntry properties are assigned.
  • If I repack the ZIP files (with 7zip), ReaderFactory then works fine.

Unfortunately, I am not at liberty to share the offending archives. Instead, I have attached the output from Info-Zip from an original and repacked file. I hope some information can be gleaned from them. If I had to guess, I would say it is a problem with the zip headers.

archive.zip.txt
archive-repack.zip.txt

Originally created by @jbrockerville on GitHub (Jul 31, 2023). I have ZIP files created with a unknown app. I am accessing the `IEntry` entries via the `ReaderFactory` (a la [USAGE.md](https://github.com/adamhathcock/sharpcompress/blob/master/USAGE.md#use-readerfactory-to-autodetect-archive-type-and-open-the-entry-stream-1)). The entries contain their key, but all the other properties (e.g., CRC, uncompressed size, compressed size, various date-times, etc.) are not assigned (set to zero or null). A couple interesting observations: - Despite the unassigned `IEntry` properties, opening the entry stream and copying it works fine. - If I use `ArchiveFactory` to access these ZIP files, their `IEntry` properties *are* assigned. - If I repack the ZIP files (with 7zip), `ReaderFactory` then works fine. Unfortunately, I am not at liberty to share the offending archives. Instead, I have attached the output from Info-Zip from an original and repacked file. I hope some information can be gleaned from them. If I had to guess, I would say it is a problem with the zip headers. [archive.zip.txt](https://github.com/adamhathcock/sharpcompress/files/12221621/archive.zip.txt) [archive-repack.zip.txt](https://github.com/adamhathcock/sharpcompress/files/12221622/archive-repack.zip.txt)
claunia added the bugquestionup for grabs labels 2026-01-29 22:14:07 +00:00
Author
Owner

@Erior commented on GitHub (Sep 4, 2023):

The archive is probably written in a Stream mode, that is when you don't know that size of the file being added.
CRC and sizes would then be 0, date time etc might or might not be set.
And it comforms with your statements above and also the dump you generated with Info-Zip

Check the test file Zip.none.datadescriptors.zip

You can use zipdetails command if it is available to you, it should show the "Local Header" information.

@Erior commented on GitHub (Sep 4, 2023): The archive is probably written in a Stream mode, that is when you don't know that size of the file being added. CRC and sizes would then be 0, date time etc might or might not be set. And it comforms with your statements above and also the dump you generated with Info-Zip Check the test file Zip.none.datadescriptors.zip You can use zipdetails command if it is available to you, it should show the "Local Header" information.
Author
Owner

@adamhathcock commented on GitHub (Sep 7, 2023):

To echo what @Erior it saying: if the zips were made with Streaming mode, the File Headers have missing data. There should be Flie Trailers that have sizes and CRC.

These can't be known ahead of time with Reader because the file sizes, etc are unknown with Reader mode and Streaming zips

@adamhathcock commented on GitHub (Sep 7, 2023): To echo what @Erior it saying: if the zips were made with Streaming mode, the File Headers have missing data. There should be Flie Trailers that have sizes and CRC. These can't be known ahead of time with Reader because the file sizes, etc are unknown with Reader mode and Streaming zips
Author
Owner

@jbrockerville commented on GitHub (Sep 7, 2023):

Huh... I was unaware that you could do that. I guess I just learned something. I can accept that explanation. Thanks for looking into it and replying. I've made a solution to handle when we encounter an archive like this. But it's nice to know it's a feature, not a bug. ;)

Maybe add some words somewhere describing this possibility?

@jbrockerville commented on GitHub (Sep 7, 2023): Huh... I was unaware that you could do that. I guess I just learned something. I can accept that explanation. Thanks for looking into it and replying. I've made a solution to handle when we encounter an archive like this. But it's nice to know it's a feature, not a bug. ;) Maybe add some words somewhere describing this possibility?
Author
Owner

@adamhathcock commented on GitHub (Sep 8, 2023):

It's not really a feature, just a known short coming of Reader (Streaming mode) and Streaming made zip files.

How do you suggest describing it? People always want more docs but I haven't found a good way to for this project as well as in my day job :)

@adamhathcock commented on GitHub (Sep 8, 2023): It's not really a feature, just a known short coming of Reader (Streaming mode) and Streaming made zip files. How do you suggest describing it? People always want more docs but I haven't found a good way to for this project as well as in my day job :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#580