Set FileOffset field in central directory header to special value when including FileOffset in ZIP64 extra fields#171
Merged
Conversation
…uding file offset in central diretory extra fields
will-malisch
approved these changes
Dec 14, 2023
ctalkington
approved these changes
Feb 27, 2024
ctalkington
left a comment
Member
There was a problem hiding this comment.
thanks for the research here
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes the root cause of issue 371 in node-archiver. This should directly fix this issue when this PR is merged here, when node-zip-stream is updated to use this new version of node-compress-commons, and then when node-archiver is updated to use the new version of node-zip-stream.
Reason for the defect:
Source: https://libzip.org/specifications/extrafld.txt
In the
ZipArchiveOutputStream._writeCentralFileHeadermethod here, if the File Offset was smaller than the Zip64 limit (0xFFFFFFFF) but the Zip64 fields were needed for another large value (example: if the uncompressed file size is larger than 0xFFFFFFFF) then the File Offset was included in the Zip64 extra field but the normal 4-byte File Offset field in the central directory header, rather than the required value of 0xFFFFFFFF.Validation:
{ zlib: { level: 6 }, forceZip64: true }. Using 7Zip, I can unzip the file successfully but it gives the warning message "Warnings: Headers Error". Opening the zip file in 7Zip and viewing the properties of the file within, it shows "Characteristics: Extra_ERROR Zip64_ERROR : Descriptor".{ zlib: { level: 6 }, forceZip64: true }. Using 7Zip, I can unzip the file successfully with no warning or error messages. Opening the zip file in 7Zip and viewing the properties of the file within, it shows "Characteristics: Zip64 : Descriptor".I have not added nor updated any unit tests, as I didn't find any tests that cover the modified areas of code or provide a framework to test these specific changes.