Skip to content

Commit 64c612c

Browse files
dschoethomson
authored andcommitted
Protect against 8.3 "short name" attacks also on Linux/macOS
The Windows Subsystem for Linux (WSL) is getting increasingly popular, in particular because it makes it _so_ easy to run Linux software on Windows' files, via the auto-mounted Windows drives (`C:\` is mapped to `/mnt/c/`, no need to set that up manually). Unfortunately, files/directories on the Windows drives can be accessed via their _short names_, if that feature is enabled (which it is on the `C:` drive by default). Which means that we have to safeguard even our Linux users against the short name attacks. Further, while the default options of CIFS/SMB-mounts seem to disallow accessing files on network shares via their short names on Linux/macOS, it _is_ possible to do so with the right options. So let's just safe-guard against short name attacks _everywhere_. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent d29d4de commit 64c612c

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/checkout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1271,7 +1271,7 @@ static int checkout_verify_paths(
12711271
int action,
12721272
git_diff_delta *delta)
12731273
{
1274-
unsigned int flags = GIT_PATH_REJECT_WORKDIR_DEFAULTS;
1274+
unsigned int flags = GIT_PATH_REJECT_WORKDIR_DEFAULTS | GIT_PATH_REJECT_DOT_GIT_NTFS;
12751275

12761276
if (action & CHECKOUT_ACTION__REMOVE) {
12771277
if (!git_path_isvalid(repo, delta->old_file.path, delta->old_file.mode, flags)) {

tests/checkout/nasty.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,8 @@ void test_checkout_nasty__dot_git_dot(void)
206206
*/
207207
void test_checkout_nasty__git_tilde1(void)
208208
{
209-
#ifdef GIT_WIN32
210209
test_checkout_fails("refs/heads/git_tilde1", ".git/foobar");
211-
#endif
210+
test_checkout_fails("refs/heads/git_tilde1", "git~1/foobar");
212211
}
213212

214213
/* A tree that contains an entry "git~2", when we have forced the short

0 commit comments

Comments
 (0)