fix(zip): complete ZIP64 header validation - #3546
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6720fe9d6d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (uncompressedSize === ZIP64_UINT32_SENTINEL) { | ||
| expectedZip64Fields.push({name: 'uncompressedSize', byteLength: 8}); | ||
| } | ||
| if (compressedSize === BigInt(0xffffffff)) { | ||
| compressedSize = extraDataBuffer.getBigUint64(offsetInZip64Data, true); | ||
| offsetInZip64Data += 8; | ||
| if (compressedSize === ZIP64_UINT32_SENTINEL) { | ||
| expectedZip64Fields.push({name: 'compressedSize', byteLength: 8}); |
There was a problem hiding this comment.
Accept the mandatory local ZIP64 size pair
When a local header has only the uncompressed legacy size set to 0xffffffff (for example, a highly compressible file whose original size exceeds 4 GiB but whose compressed size still fits in 32 bits), this builds an expected ZIP64 payload containing only uncompressedSize. ZIP64 local-header entries must include both original and compressed size values (PKWARE APPNOTE 4.5.3), so those archives carry a 16-byte ZIP64 payload and now fail fetch() with unexpected payload size even though the central directory can provide the compressed length. For local headers, request both size fields whenever either legacy size uses ZIP64.
Useful? React with 👍 / 👎.
Goals
DataViewrange failures with consistent archive-corruption errors.Changes
ZipFileSystemregression tests covering missing/truncated records, unrelated records and payload bytes, field ordering, andreaddir()/stat()/fetch()errors.Invalid ZIP archivepolicy for malformed ZIP64 metadata.Validation
yarnyarn lint fixyarn buildyarn test-node— 1,928 passed, 81 skippedyarn test-headless— 1,893 passed, 60 skippedFixes #3545