Skip to content

Commit 91bd465

Browse files
committed
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 <[email protected]>
1 parent 7c3745f commit 91bd465

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

path.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ static int is_ntfs_dot_generic(const char *name,
13691369
only_spaces_and_periods:
13701370
for (;;) {
13711371
char c = name[i++];
1372-
if (!c)
1372+
if (!c || c == ':')
13731373
return 1;
13741374
if (c != ' ' && c != '.')
13751375
return 0;

t/t0060-path-utils.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,9 @@ test_expect_success 'match .gitmodules' '
408408
~1000000 \
409409
~9999999 \
410410
\
411+
.gitmodules:\$DATA \
412+
"gitmod~4 . :\$DATA" \
413+
\
411414
--not \
412415
".gitmodules x" \
413416
".gitmodules .x" \
@@ -432,7 +435,9 @@ test_expect_success 'match .gitmodules' '
432435
\
433436
GI7EB~1 \
434437
GI7EB~01 \
435-
GI7EB~1X
438+
GI7EB~1X \
439+
\
440+
.gitmodules,:\$DATA
436441
'
437442

438443
test_done

0 commit comments

Comments
 (0)