Skip to content

fix: strip file-type bits from ZIP external_attributes in list -l output#90

Merged
bug-ops merged 1 commit intomainfrom
bug-list-l-shows-raw-numeric-un
Mar 15, 2026
Merged

fix: strip file-type bits from ZIP external_attributes in list -l output#90
bug-ops merged 1 commit intomainfrom
bug-list-l-shows-raw-numeric-un

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 15, 2026

Summary

  • list -l displayed raw Unix file-type bits for ZIP entries (e.g. 100644 instead of 644) because ZipFile::unix_mode() returns external_attributes >> 16, which includes S_IFREG/S_IFDIR bits from archives created by external Unix tools
  • Fix: mask the value with & 0o7777 when storing it in ArchiveEntry.mode, keeping only the permission bits — matching the behavior of TAR entries

Test plan

  • test_zip_mode_strips_s_ifreg_bits: crafts a raw ZIP with 0o100644 in external_attributes, verifies mode = Some(0o644)
  • test_zip_mode_strips_s_ifdir_bits: crafts a raw ZIP with 0o040755, verifies mode = Some(0o755)
  • test_zip_mode_permission_bits_unchanged: permission-only value preserved after masking
  • test_tar_and_zip_mode_consistent: TAR 0o644 and ZIP 0o100644 produce identical ArchiveEntry.mode
  • All 515 tests pass

Fixes #80

ZIP archives created by Unix tools store the full stat(2) mode in
external_attributes (e.g. 0o100644 = S_IFREG|0o644, 0o040755 = S_IFDIR|0o755).
The zip crate's unix_mode() returns external_attributes >> 16, which includes
these file-type bits. ArchiveEntry.mode now masks the value with 0o7777 so that
only permission bits are stored, matching the output of TAR entries.

Fixes #80
@github-actions github-actions bot added core Changes to exarch-core docs Documentation labels Mar 15, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 15, 2026 00:22
@bug-ops bug-ops merged commit 2f0b3c3 into main Mar 15, 2026
20 checks passed
@bug-ops bug-ops deleted the bug-list-l-shows-raw-numeric-un branch March 15, 2026 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Changes to exarch-core docs Documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: list -l shows raw numeric Unix mode for ZIP, inconsistent with TAR

1 participant