Recognize CONOUT$ and CONIN$ as reserved device names (#13508)

This commit is contained in:
David Reis 2020-09-14 19:10:12 +01:00 committed by GitHub
parent d25d964d57
commit 3effa20410
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -1258,14 +1258,14 @@ namespace System.Management.Automation
internal static bool IsReservedDeviceName(string destinationPath)
{
#if !UNIX
string[] reservedDeviceNames = { "CON", "PRN", "AUX", "CLOCK$", "NUL",
string[] reservedDeviceNames = { "CON", "PRN", "AUX", "CLOCK$", "NUL", "CONIN$", "CONOUT$",
"COM0", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
"LPT0", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9" };
string compareName = Path.GetFileName(destinationPath);
string noExtensionCompareName = Path.GetFileNameWithoutExtension(destinationPath);
if (((compareName.Length < 3) || (compareName.Length > 6)) &&
((noExtensionCompareName.Length < 3) || (noExtensionCompareName.Length > 6)))
if (((compareName.Length < 3) || (compareName.Length > 7)) &&
((noExtensionCompareName.Length < 3) || (noExtensionCompareName.Length > 7)))
{
return false;
}

View file

@ -28,6 +28,8 @@ Describe "Basic FileSystem Provider Tests" -Tags "CI" {
@{ deviceName = 'AUX' }
@{ deviceName = 'CLOCK$' }
@{ deviceName = 'NUL' }
@{ deviceName = 'CONIN$' }
@{ deviceName = 'CONOUT$' }
@{ deviceName = 'COM0' }
@{ deviceName = 'COM1' }
@{ deviceName = 'COM2' }