-
Notifications
You must be signed in to change notification settings - Fork 140
Refuse to write to reserved filenames on Windows #496
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
Conversation
In the next commit, we want to disallow accessing any path that contains any segment that is equivalent to `NUL`. In particular, we want to disallow accessing `NUL` (e.g. to prevent any repository from being checked out that contains a file called `NUL`, as that is not a valid file name on Windows). However, there are legitimate use cases within Git itself to write to the Null device. As Git is really a Linux project, it does not abstract that idea, though, but instead uses `/dev/null` to describe this intention. So let's side-step the validation _specifically_ in the case that we want to write to (or read from) `/dev/null`, via a dedicated short-cut in the code that skips the call to `validate_win32_path()`. Signed-off-by: Johannes Schindelin <[email protected]>
There are a couple of reserved names that cannot be file names on Windows, such as `AUX`, `NUL`, etc. For an almost complete list, see https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file If one would try to create a directory named `NUL`, it would actually "succeed", i.e. the call would return success, but nothing would be created. Worse, even adding a file extension to the reserved name does not make it a valid file name. To understand the rationale behind that behavior, see https://devblogs.microsoft.com/oldnewthing/20031022-00/?p=42073 Let's just disallow them all. Signed-off-by: Johannes Schindelin <[email protected]>
/submit |
Submitted as [email protected] |
This branch is now known as |
This patch series was integrated into pu via git@19df3e0. |
This patch series was integrated into pu via git@29cfef7. |
This patch series was integrated into pu via git@56a7159. |
This patch series was integrated into pu via git@74542f4. |
This patch series was integrated into pu via git@c8499a2. |
This patch series was integrated into next via git@5b814fd. |
This patch series was integrated into pu via git@b612456. |
This patch series was integrated into pu via git@13432fc. |
This patch series was integrated into next via git@13432fc. |
This patch series was integrated into master via git@13432fc. |
Closed via 13432fc. |
On Windows, for historical reasons, file names such as
aux.c
,nul.txt
are not allowed. Foraux.c
, attempts to write such a file will result in an obscure error, fornul.txt
the call will succeed but no such file will appear, ever, instead the effect will be equivalent to writing to/dev/null
on Linux/Unix.Let's help users by refusing to create such files altogether, with an informative error message.