forked from git/git
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Refuse to write to reserved filenames #2440
Merged
dscho
merged 3 commits into
git-for-windows:master
from
dscho:mingw-reserved-filenames-gfw
Dec 26, 2019
Merged
Refuse to write to reserved filenames #2440
dscho
merged 3 commits into
git-for-windows:master
from
dscho:mingw-reserved-filenames-gfw
Dec 26, 2019
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 <johannes.schindelin@gmx.de>
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 <johannes.schindelin@gmx.de>
This topic branch refuses to create files with reserved file names, such as `aux.c` or `nul.txt`. This addresses git-for-windows#679. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho
added a commit
to dscho/git
that referenced
this pull request
Dec 27, 2019
…enames-gfw Refuse to write to reserved filenames
git-for-windows-ci
pushed a commit
that referenced
this pull request
Dec 29, 2019
Refuse to write to reserved filenames
dscho
added a commit
that referenced
this pull request
Dec 29, 2019
Refuse to write to reserved filenames
This was referenced Jan 1, 2020
dscho
added a commit
that referenced
this pull request
Jan 4, 2020
Refuse to write to reserved filenames
1 task
dscho
added a commit
that referenced
this pull request
Jan 13, 2020
Refuse to write to reserved filenames
git-for-windows-ci
pushed a commit
that referenced
this pull request
Jan 16, 2020
Refuse to write to reserved filenames
git-for-windows-ci
pushed a commit
that referenced
this pull request
Jan 17, 2020
Refuse to write to reserved filenames
git-for-windows-ci
pushed a commit
that referenced
this pull request
Jan 22, 2020
Refuse to write to reserved filenames
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a companion PR to gitgitgadget#496 (including a merge commit needed to sort out merge conflicts with the
core.longPaths
feature).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.
This addresses #679 and supersedes #686