-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix infinite recursion writing to removable drives mounted to NTFS folders #3415
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 infinite recursion writing to removable drives mounted to NTFS folders #3415
Conversation
…adLink can return the passed in path if it refers to an "NT Object Manager" path, and we need to handle this as if it isn't a reparse point, because we can't follow the link. This generalizes the fix by @seando-adsk in f6c2e82, by handling mounted volumes on Windows and avoiding infinitely recursive calls to TfReadLink by having TfIsLink return false in cases where this bad behavior could arise.
|
Filed as internal issue #USD-10419 |
|
/AzurePipelines run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
anwang2009
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @marktucker, this PR looks great - just one comment
| // Read symlinks until we find the real file. | ||
| return Tf_HasAttribute(TfReadLink(path.c_str()), resolveSymlinks, | ||
| attribute, expected); | ||
| return Tf_HasAttribute(linkPath, resolveSymlinks, attribute, expected); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit tricky to tell that linkPath is non-empty from reading the code; it'd be great if that could be made more obvious
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is an additional comment around line 117 sufficient? Something like:
// At this point we know (attribs & FILE_ATTRIBUTE_REPARSE_POINT) != 0
// or we would have returned in the if block above. This means linkPath will
// be holding the result of calling TfReadLink(path.c_str()). The code is separated
// in this way to avoid calling TfReadLink twice.
|
Yeah, that’s fair - thanks!
…On Wed, Feb 26, 2025 at 11:06 AM Mark Tucker ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In pxr/base/tf/fileUtils.cpp
<#3415 (comment)>
:
> @@ -106,8 +115,7 @@ Tf_HasAttribute(
}
// Read symlinks until we find the real file.
- return Tf_HasAttribute(TfReadLink(path.c_str()), resolveSymlinks,
- attribute, expected);
+ return Tf_HasAttribute(linkPath, resolveSymlinks, attribute, expected);
Is an additional comment around line 117 sufficient? Something like:
// At this point we know (attribs & FILE_ATTRIBUTE_REPARSE_POINT) != 0
// or we would have returned in the if block above. This means linkPath
will
// be holding the result of calling TfReadLink(path.c_str()). The code is
separated
// in this way to avoid calling TfReadLink twice.
—
Reply to this email directly, view it on GitHub
<#3415 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADGZPGJGBIU33D4OMCYRDP32RYGCZAVCNFSM6AAAAABRMENEJSVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDMNBVGU4TKOJTGQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Tf_HasAttribute to address confusion expressed in the PR review.
Fix another issue with unresolvable reparse points on Windows. ArchReadLink
can return the passed in path if it refers to an "NT Object Manager" path, and we need to handle this as if it isn't a reparse point, because we can't follow the link.
This generalizes the fix by @seando-adsk in f6c2e82, by handling mounted volumes on Windows and avoiding infinitely recursive calls to TfReadLink by having TfIsLink return false in cases where this bad behavior could arise.
Description of Change(s)
Changed Tf_HasAttribute to remove the reparse point attribute on a directory if TfReadLink returns the original path or an empty string (i.e. we couldn't follow the link). This means TfIsLink returns false in these cases, preventing recursive calls to TfReadLink because we always call TfIsLink before calling TfReadLink.
Fixes Issue(s)
#3414
Checklist
[ X ] I have created this PR based on the dev branch
[ X ] I have followed the coding conventions
[ ] I have added unit tests that exercise this functionality
Unit testing this is basically impossible given the complex steps required to set up the USB drive appropriately.
[ X ] I have verified that all unit tests pass with the proposed changes
[ X ] I have submitted a signed Contributor License Agreement (Reference: