Fix zip unix permissions - #130304
Conversation
…ession test Co-authored-by: alinpahontu2912 <56953855+alinpahontu2912@users.noreply.github.com>
Co-authored-by: alinpahontu2912 <56953855+alinpahontu2912@users.noreply.github.com>
Co-authored-by: alinpahontu2912 <56953855+alinpahontu2912@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR changes Unix extraction behavior in System.IO.Compression.ZipFile so that Unix permission bits from ExternalAttributes are only applied when the ZIP entry’s “version made by” platform indicates Unix, preventing Windows-made entries from having their Windows attributes misinterpreted as Unix file modes. It also adds a regression test to validate the intended behavior.
Changes:
- Gate
UnixCreateModeapplication onVersionMadeByplatform being Unix (3) during extraction on non-Windows OSes. - Add a Unix regression test that verifies Windows-made entries do not have Unix permission bits applied.
- Add a small test helper to patch the entry’s “version made by” platform in the central directory record.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/libraries/System.IO.Compression.ZipFile/tests/ZipFile.Unix.cs | Adds a regression test + helper to validate permissions aren’t applied for Windows-made entries. |
| src/libraries/System.IO.Compression.ZipFile/src/System/IO/Compression/ZipFileExtensions.ZipArchiveEntry.Extract.cs | Restricts Unix permission restoration to entries marked as Unix-made via VersionMadeBy. |
Copilot Code ReviewHolistic AssessmentMotivation: The PR addresses a real bug — when extracting zip entries created on Windows (or with a non-Unix platform ID), the upper 16 bits of Approach: The fix correctly uses the Summary: ✅ LGTM. The fix is correct, well-scoped, and the test properly validates the behavior. One minor suggestion below regarding naming, and one observation about platform coverage, but neither is blocking. Detailed FindingsDetailed Findings✅ Correctness — Platform check is soundThe fix extracts the platform byte from
The local ✅ Existing test compatibilityExisting tests still pass because:
✅ Test quality — Good regression testThe test creates a zip with explicit permission bits, patches the binary to simulate a Windows-originated entry (platform 0), then verifies that extraction uses default system permissions rather than the embedded bits. The binary patching via 💡 Naming —
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Fixes #94465