Skip to content

fix: change directory attributes detection#851

Open
Its-Just-Nans wants to merge 5 commits into
masterfrom
fix-attributes
Open

fix: change directory attributes detection#851
Its-Just-Nans wants to merge 5 commits into
masterfrom
fix-attributes

Conversation

@Its-Just-Nans
Copy link
Copy Markdown
Member

WIP for #737

Copy link
Copy Markdown
Contributor

@amazon-q-developer amazon-q-developer Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

This PR modifies the directory attributes detection logic in src/types.rs. While the reorganization of constants and improved documentation are good, there is a critical logic error in the MS-DOS symlink detection that needs to be addressed.

Critical Issue

The new symlink check in the System::Dos branch incorrectly interprets the high 16 bits of external_attributes as Unix mode. According to the ZIP specification, for DOS-system archives, only the low 16 bits are meaningful (MS-DOS attributes), and the high 16 bits should not be used for Unix-style mode detection. This could cause incorrect symlink identification.

Recommendations

Before merging, please:

  1. Review the symlink detection logic for DOS system archives
  2. Verify the behavior with test cases for DOS archives with and without the symlink bits accidentally set in the high 16 bits
  3. Ensure the changes align with APPNOTE.TXT section 4.4.15 regarding DOS compatibility

The PR is marked as WIP, so please address this issue before requesting final review.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

Comment thread src/types.rs Outdated
Comment on lines +283 to +284
} else if (unix_mode & ffi::S_IFMT) == ffi::S_IFLNK {
ffi::S_IFLNK | 0o0777
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Logic Error: The symlink check using unix_mode & ffi::S_IFMT in the System::Dos branch is incorrect. For DOS system archives, the external_attributes follow the MS-DOS specification where only the low 16 bits are meaningful (DOS attributes). The high 16 bits should not be interpreted as Unix mode for DOS systems. This check could incorrectly identify files as symlinks when the high 16 bits happen to match the symlink pattern due to uninitialized or arbitrary data. According to the ZIP specification (APPNOTE.TXT section 4.4.15), for DOS compatibility, only the low byte contains the MS-DOS directory attribute byte.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

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.

1 participant