Skip to content

Commit cd3d6b3

Browse files
dschoGit for Windows Build Agent
authored andcommitted
Merge pull request #2473 from dscho/com0-is-not-a-reserved-name
Do not mistake `COM0` for a reserved file name
2 parents 2076b92 + f578006 commit cd3d6b3

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
@@ -3230,12 +3230,14 @@ int is_valid_win32_path(const char *path, int allow_literal_nul)
32303230
continue;
32313231
}
32323232
break;
3233-
case 'c': case 'C': /* COM<N>, CON, CONIN$, CONOUT$ */
3233+
case 'c': case 'C':
3234+
/* COM1 ... COM9, CON, CONIN$, CONOUT$ */
32343235
if ((c = path[++i]) != 'o' && c != 'O')
32353236
goto not_a_reserved_name;
32363237
c = path[++i];
3237-
if (c == 'm' || c == 'M') { /* COM<N> */
3238-
if (!isdigit(path[++i]))
3238+
if (c == 'm' || c == 'M') { /* COM1 ... COM9 */
3239+
c = path[++i];
3240+
if (c < '1' || c > '9')
32393241
goto not_a_reserved_name;
32403242
} else if (c == 'n' || c == 'N') { /* CON */
32413243
c = path[i + 1];

t/t0060-path-utils.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ test_expect_success MINGW 'is_valid_path() on Windows' '
472472
C:\\git \
473473
comm \
474474
conout.c \
475+
com0.c \
475476
lptN \
476477
\
477478
--not \
@@ -484,6 +485,7 @@ test_expect_success MINGW 'is_valid_path() on Windows' '
484485
"AUX.c" \
485486
"abc/conOut\$ .xyz/test" \
486487
lpt8 \
488+
com9.c \
487489
"lpt*" \
488490
Nul \
489491
"PRN./abc"

0 commit comments

Comments
 (0)