Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug local block parsing data size, check for local size incomplete #196

Closed

Conversation

0xCCF4
Copy link

@0xCCF4 0xCCF4 commented Jun 19, 2024

In the ZIP Format Specification (version 6.3.10) it is defined that for a local file header (section 4.3.7) flag bit 3 (section 4.4.4) may be set to indicate that the data size can be found in the data descriptor. A supporting implementation must in that case set crc32, compressed and uncompressed size to zero.

From the specification:

Bit 3: If this bit is set, the fields crc-32, compressed 
               size and uncompressed size are set to zero in the 
               local header.  The correct values are put in the 
               data descriptor immediately following the compressed
               data.  (Note: PKZIP version 2.04g for DOS only 
               recognizes this bit for method 8 compression, newer 
               versions of PKZIP recognize this bit for any 
               compression method.)

We can therefore assume that if C/U size or crc32 is not set to zero in the local file header, the given size is valid and can be used to determine the content size

I observed that some zip compression utils in fact include the size in the local file header while still setting bit 3.

My contribution:

  • change the check if a local size is contained in the local entry parser
  • add tests to test this feature

In the ZIP Format Specification (version 6.3.10) it is defined that for a local file header (section 4.3.7) flag bit 3 (section 4.4.4) may be set to indicate that the data size can be found in the data descriptor. A supporting implementation must in that case set crc32, compressed and uncompressed size to zero.

We can therefore assume that if C/U size or crc32 is not set to zero in the local file header, the given size is valid and can be used to determine the content size

I observed that some zip compression utils in fact include the size in the local file header while still setting bit 3.
@Pr0methean Pr0methean enabled auto-merge June 19, 2024 20:00
@Pr0methean
Copy link
Member

Pr0methean commented Jun 19, 2024

Looks great, but could you please fix the failing style checks and unit tests?

@Pr0methean Pr0methean added the Please fix failing tests Tests are failing with this change; please fix them. label Jun 19, 2024
@0xCCF4
Copy link
Author

0xCCF4 commented Jun 20, 2024

I've done some more testing and it seems that my initial claim in #196 (comment) is not entirely true. My compressing program is not specification compliant and inserts the uncompressed size in the local file header while setting the compressed file size to zero. Which does not help with the size detection. I therefore close the PR.

@0xCCF4 0xCCF4 closed this Jun 20, 2024
auto-merge was automatically disabled June 20, 2024 08:59

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Please fix failing tests Tests are failing with this change; please fix them.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants