Handle bad extra fields in local file headers in zip files #354

Closed
opened 2026-01-29 22:10:34 +00:00 by claunia · 1 comment
Owner

Originally created by @DannyBoyk on GitHub (Jun 3, 2019).

At my work we have to process quite a few zip files whose generation we have very little control over. One of the zips we are receiving is putting custom data in the extras field of the local file header rather than following the 2 byte tag ID, 2 byte value length, and X byte value that the zip format specifies.

I traced 7zips logic on this and they just gracefully bail on further parsing of the extras field if they detect a length for an extra that is greater than the total length of the extras header. I made a similar change in ZipFileEntry and added a corresponding test. I'll be pushing up a branch and making a PR for this issue.

Originally created by @DannyBoyk on GitHub (Jun 3, 2019). At my work we have to process quite a few zip files whose generation we have very little control over. One of the zips we are receiving is putting custom data in the extras field of the local file header rather than following the 2 byte tag ID, 2 byte value length, and X byte value that the zip format specifies. I traced 7zips logic on this and they just gracefully bail on further parsing of the extras field if they detect a length for an extra that is greater than the total length of the extras header. I made a similar change in ZipFileEntry and added a corresponding test. I'll be pushing up a branch and making a PR for this issue.
Author
Owner

@adamhathcock commented on GitHub (Jun 4, 2019):

Seemed fine to me. Thanks.

@adamhathcock commented on GitHub (Jun 4, 2019): Seemed fine to me. Thanks.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#354