diff --git a/compat/mingw.c b/compat/mingw.c index bce8412685699c..c2b9b48ef65143 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -3230,12 +3230,14 @@ int is_valid_win32_path(const char *path, int allow_literal_nul) continue; } break; - case 'c': case 'C': /* COM, 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 */ - 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]; diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh index 661d3e27abe191..6dd25945b76b2f 100755 --- a/t/t0060-path-utils.sh +++ b/t/t0060-path-utils.sh @@ -472,6 +472,7 @@ test_expect_success MINGW 'is_valid_path() on Windows' ' C:\\git \ comm \ conout.c \ + com0.c \ lptN \ \ --not \ @@ -484,6 +485,7 @@ test_expect_success MINGW 'is_valid_path() on Windows' ' "AUX.c" \ "abc/conOut\$ .xyz/test" \ lpt8 \ + com9.c \ "lpt*" \ Nul \ "PRN./abc"