Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix directory iterator treating all files subsequent to a symlink as symlink on Windows #162

Merged
merged 1 commit into from
Feb 17, 2023

Conversation

Qrox
Copy link
Contributor

@Qrox Qrox commented Feb 16, 2023

According to microsoft documentation on the dwReserved0 member of _WIN32_FIND_DATAW,

If the dwFileAttributes member includes the FILE_ATTRIBUTE_REPARSE_POINT attribute, this member specifies the reparse point tag.

Otherwise, this value is undefined and should not be used.

reparse_tag_from_INFO uses dwReserved0 without checking the FILE_ATTRIBUTE_REPARSE_POINT attribute, which causes directory_iterator to use a stale dwReserved0 value for all files subsequent to a symlink, causing all of these files to be treated as symlink incorrectly.

This patch checks FILE_ATTRIBUTE_REPARSE_POINT before checking dwReserved0 to correctly get the symlink status of the files. Also replaced a hack that uses structure size to determine structure type with proper templates.

This patch is tested on CleverRaven/Cataclysm-DDA#63612 and cherrypicked from that PR.

Fix directory iterator treating all files subsequent to a symlink as symlink on Windows
@gulrak
Copy link
Owner

gulrak commented Feb 17, 2023

Thank you for the fix!

@gulrak gulrak merged commit 655b0b3 into gulrak:master Feb 17, 2023
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.

None yet

2 participants