Skip to content

Commit e3a910a

Browse files
committed
Merge pull request #2473 from dscho/com0-is-not-a-reserved-name
Do not mistake `COM0` for a reserved file name
2 parents 10b7b39 + 53be4f6 commit e3a910a

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
@@ -2781,12 +2781,14 @@ int is_valid_win32_path(const char *path, int allow_literal_nul)
27812781
continue;
27822782
}
27832783
break;
2784-
case 'c': case 'C': /* COM<N>, CON, CONIN$, CONOUT$ */
2784+
case 'c': case 'C':
2785+
/* COM1 ... COM9, CON, CONIN$, CONOUT$ */
27852786
if ((c = path[++i]) != 'o' && c != 'O')
27862787
goto not_a_reserved_name;
27872788
c = path[++i];
2788-
if (c == 'm' || c == 'M') { /* COM<N> */
2789-
if (!isdigit(path[++i]))
2789+
if (c == 'm' || c == 'M') { /* COM1 ... COM9 */
2790+
c = path[++i];
2791+
if (c < '1' || c > '9')
27902792
goto not_a_reserved_name;
27912793
} else if (c == 'n' || c == 'N') { /* CON */
27922794
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)