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
os: File.Stat on Windows doesn't use file handle for directories #52747
Comments
Change https://go.dev/cl/405275 mentions this issue: |
I've been investigating this issue lately, and I've found that This change breaks directory traversal, as readdir is expecting a handle created via I've done a working prototype of this idea in CL 405275. I'm also pretty sure that there is no need to use the path-based |
Another side effect of CL 405275: The directory handle created by This means it wouldn't be possible to move or remove an opened directory, just as it is already happening with normal opened files. @alexbrainman @mattn thoughts? |
How does |
This is the current behavior:
So one could say that the current behavior of CL 405275 changes how directory handles are constructed, instead of using |
On Windows
File.Stat
doesn't use the file handle to retrieve attributes when the file is a directory, due to the lack of a...ByHandle
Windows API which works on directories (GetFileInformationByHandle
only works on files), using the path instead.This means there may be a TOCTOU issue, as the results returned by
Stat
represent the attributes for the file at the path passed toOpen
, which may no longer be the file represented by the file handle if the file has been moved/replaced.The text was updated successfully, but these errors were encountered: