Skip to content

Commit

Permalink
Merge pull request #2473 from dscho/com0-is-not-a-reserved-name
Browse files Browse the repository at this point in the history
Do not mistake `COM0` for a reserved file name
  • Loading branch information
dscho committed Jan 16, 2020
2 parents 4001aef + e3578e3 commit 8f03c5e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions compat/mingw.c
Expand Up @@ -3231,12 +3231,14 @@ int is_valid_win32_path(const char *path, int allow_literal_nul)
continue;
}
break;
case 'c': case 'C': /* COM<N>, CON, CONIN$, CONOUT$ */
case 'c': case 'C':
/* COM1 ... COM9, CON, CONIN$, CONOUT$ */
if ((c = path[++i]) != 'o' && c != 'O')
goto not_a_reserved_name;
c = path[++i];
if (c == 'm' || c == 'M') { /* COM<N> */
if (!isdigit(path[++i]))
if (c == 'm' || c == 'M') { /* COM1 ... COM9 */
c = path[++i];
if (c < '1' || c > '9')
goto not_a_reserved_name;
} else if (c == 'n' || c == 'N') { /* CON */
c = path[i + 1];
Expand Down
2 changes: 2 additions & 0 deletions t/t0060-path-utils.sh
Expand Up @@ -476,6 +476,7 @@ test_expect_success MINGW 'is_valid_path() on Windows' '
C:\\git \
comm \
conout.c \
com0.c \
lptN \
\
--not \
Expand All @@ -488,6 +489,7 @@ test_expect_success MINGW 'is_valid_path() on Windows' '
"AUX.c" \
"abc/conOut\$ .xyz/test" \
lpt8 \
com9.c \
"lpt*" \
Nul \
"PRN./abc"
Expand Down

0 comments on commit 8f03c5e

Please sign in to comment.