Skip to content
Permalink
Browse files
Merge pull request #2473 from dscho/com0-is-not-a-reserved-name
Do not mistake `COM0` for a reserved file name
  • Loading branch information
dscho committed Jan 16, 2020
2 parents 4001aef + e3578e3 commit 8f03c5ece6b73e7facf93b354b0fd8705d064dd2
Showing with 7 additions and 3 deletions.
  1. +5 −3 compat/mingw.c
  2. +2 −0 t/t0060-path-utils.sh
@@ -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];
@@ -476,6 +476,7 @@ test_expect_success MINGW 'is_valid_path() on Windows' '
C:\\git \
comm \
conout.c \
com0.c \
lptN \
\
--not \
@@ -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"

0 comments on commit 8f03c5e

Please sign in to comment.