Skip to content

Use the actual length of data descriptors when removing entries - #433

Merged
weichsel merged 2 commits into
fix/consolidate-stored-data-sizefrom
fix/data-descriptor-length
Nov 18, 2026
Merged

weichsel merged 2 commits into
fix/consolidate-stored-data-sizefrom
fix/data-descriptor-length

Conversation

@weichsel

@weichsel weichsel commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Entry.localSize now uses the length of the data descriptor as it is stored in the archive:

  • Descriptors without a signature are 4 bytes shorter.
  • A ZIP64 entry whose descriptor matches neither layout has 8 byte sizes only if its local file header has ZIP64 extended information, as streaming readers assume (cf. APPNOTE 4.3.9.2, which says "for the file").

Before, Archive.remove copied the first bytes of the following entry into the rewritten archive, and totalUnitCountForRemoving was off by the same amount.

Fixes #435. Stacked on #432.

@weichsel
weichsel force-pushed the fix/data-descriptor-length branch from b9d45ca to 7c4c318 Compare November 18, 2026 16:56
`Entry.localSize` always added the size of a descriptor with a signature, but descriptors
without one are 4 bytes shorter. A ZIP64 entry whose descriptor matched neither layout was
always treated as having 8 byte sizes. It now has 8 byte sizes only if its local file header
has ZIP64 extended information. In both cases, `Archive.remove` copied bytes of the following
entry into the rewritten archive.
@weichsel
weichsel force-pushed the fix/data-descriptor-length branch from 7c4c318 to e00709a Compare November 18, 2026 17:04
@weichsel
weichsel added this pull request to stack #436 November 18, 2026 19:18
The local file header of the entry has ZIP64 extended information, so the
descriptor with 8 byte sizes is kept although neither layout matches.
@weichsel
weichsel merged commit 19ea907 into main Nov 18, 2026
13 checks passed
@weichsel
weichsel deleted the fix/data-descriptor-length branch November 18, 2026 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Removing an entry copies 4 extra bytes after data descriptors without a signature

1 participant