Skip to content

Commit e1832eb

Browse files
dschoethomson
authored andcommitted
path: also guard .gitmodules against NTFS Alternate Data Streams
We just safe-guarded `.git` against NTFS Alternate Data Stream-related attack vectors, and now it is time to do the same for `.gitmodules`. Note: In the added regression test, we refrain from verifying all kinds of variations between short names and NTFS Alternate Data Streams: as the new code disallows _all_ Alternate Data Streams of `.gitmodules`, it is enough to test one in order to know that all of them are guarded against. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 3f7851e commit e1832eb

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/path.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,7 @@ GIT_INLINE(bool) only_spaces_and_dots(const char *path)
16461646
const char *c = path;
16471647

16481648
for (;; c++) {
1649-
if (*c == '\0')
1649+
if (*c == '\0' || *c == ':')
16501650
return true;
16511651
if (*c != ' ' && *c != '.')
16521652
return false;

tests/path/dotgit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,5 @@ void test_path_dotgit__dotgit_modules_symlink(void)
116116
cl_assert_equal_b(true, git_path_isvalid(NULL, ".gitmodules", 0, GIT_PATH_REJECT_DOT_GIT_HFS|GIT_PATH_REJECT_DOT_GIT_NTFS));
117117
cl_assert_equal_b(false, git_path_isvalid(NULL, ".gitmodules", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_HFS));
118118
cl_assert_equal_b(false, git_path_isvalid(NULL, ".gitmodules", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_NTFS));
119+
cl_assert_equal_b(false, git_path_isvalid(NULL, ".gitmodules . .::$DATA", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_NTFS));
119120
}

0 commit comments

Comments
 (0)