Skip to content

Commit 252d53b

Browse files
dschoGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
Merge pull request #2473 from dscho/com0-is-not-a-reserved-name
Do not mistake `COM0` for a reserved file name
2 parents 978b163 + aa3de99 commit 252d53b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

compat/mingw.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3231,12 +3231,14 @@ int is_valid_win32_path(const char *path, int allow_literal_nul)
32313231
continue;
32323232
}
32333233
break;
3234-
case 'c': case 'C': /* COM<N>, CON, CONIN$, CONOUT$ */
3234+
case 'c': case 'C':
3235+
/* COM1 ... COM9, CON, CONIN$, CONOUT$ */
32353236
if ((c = path[++i]) != 'o' && c != 'O')
32363237
goto not_a_reserved_name;
32373238
c = path[++i];
3238-
if (c == 'm' || c == 'M') { /* COM<N> */
3239-
if (!isdigit(path[++i]))
3239+
if (c == 'm' || c == 'M') { /* COM1 ... COM9 */
3240+
c = path[++i];
3241+
if (c < '1' || c > '9')
32403242
goto not_a_reserved_name;
32413243
} else if (c == 'n' || c == 'N') { /* CON */
32423244
c = path[i + 1];

t/t0060-path-utils.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ test_expect_success MINGW 'is_valid_path() on Windows' '
476476
C:\\git \
477477
comm \
478478
conout.c \
479+
com0.c \
479480
lptN \
480481
\
481482
--not \
@@ -488,6 +489,7 @@ test_expect_success MINGW 'is_valid_path() on Windows' '
488489
"AUX.c" \
489490
"abc/conOut\$ .xyz/test" \
490491
lpt8 \
492+
com9.c \
491493
"lpt*" \
492494
Nul \
493495
"PRN./abc"

0 commit comments

Comments
 (0)