mirror of
https://github.com/reactos/reactos.git
synced 2024-09-10 21:04:26 +00:00
[RTL]
Fix RtlIsNameLegalDOS8Dot3 regression svn path=/trunk/; revision=58324
This commit is contained in:
parent
e506c7ce61
commit
ebaac9c9e5
|
@ -225,12 +225,18 @@ RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
|
* Note: the function does not conform to the annotations.
|
||||||
|
* SpacesFound is not always set!
|
||||||
*/
|
*/
|
||||||
|
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||||
|
_Must_inspect_result_
|
||||||
|
NTSYSAPI
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NTAPI
|
NTAPI
|
||||||
RtlIsNameLegalDOS8Dot3(IN PCUNICODE_STRING UnicodeName,
|
RtlIsNameLegalDOS8Dot3 (
|
||||||
IN OUT POEM_STRING AnsiName OPTIONAL,
|
_In_ PCUNICODE_STRING Name,
|
||||||
IN OUT PBOOLEAN SpacesFound OPTIONAL)
|
_Inout_opt_ POEM_STRING OemName,
|
||||||
|
_Out_opt_ PBOOLEAN NameContainsSpaces)
|
||||||
{
|
{
|
||||||
static const char Illegal[] = "*?<>|\"+=,;[]:/\\\345";
|
static const char Illegal[] = "*?<>|\"+=,;[]:/\\\345";
|
||||||
int Dot = -1;
|
int Dot = -1;
|
||||||
|
@ -240,36 +246,35 @@ RtlIsNameLegalDOS8Dot3(IN PCUNICODE_STRING UnicodeName,
|
||||||
BOOLEAN GotSpace = FALSE;
|
BOOLEAN GotSpace = FALSE;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
if (SpacesFound) *SpacesFound = FALSE;
|
if (!OemName)
|
||||||
|
|
||||||
if (!AnsiName)
|
|
||||||
{
|
{
|
||||||
OemString.Length = sizeof(Buffer);
|
OemString.Length = sizeof(Buffer);
|
||||||
OemString.MaximumLength = sizeof(Buffer);
|
OemString.MaximumLength = sizeof(Buffer);
|
||||||
OemString.Buffer = Buffer;
|
OemString.Buffer = Buffer;
|
||||||
AnsiName = &OemString;
|
OemName = &OemString;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = RtlUpcaseUnicodeStringToCountedOemString(AnsiName, UnicodeName, FALSE);
|
Status = RtlUpcaseUnicodeStringToCountedOemString(OemName, Name, FALSE);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if ((AnsiName->Length > 12) || (AnsiName->Buffer == NULL)) return FALSE;
|
if ((OemName->Length > 12) || (OemName->Buffer == NULL)) return FALSE;
|
||||||
|
|
||||||
/* a starting . is invalid, except for . and .. */
|
/* a starting . is invalid, except for . and .. */
|
||||||
if (AnsiName->Buffer[0] == '.')
|
if (OemName->Buffer[0] == '.')
|
||||||
{
|
{
|
||||||
if (AnsiName->Length != 1 && (AnsiName->Length != 2 || AnsiName->Buffer[1] != '.')) return FALSE;
|
if (OemName->Length != 1 && (OemName->Length != 2 || OemName->Buffer[1] != '.')) return FALSE;
|
||||||
|
if (NameContainsSpaces) *NameContainsSpaces = FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < AnsiName->Length; i++)
|
for (i = 0; i < OemName->Length; i++)
|
||||||
{
|
{
|
||||||
switch (AnsiName->Buffer[i])
|
switch (OemName->Buffer[i])
|
||||||
{
|
{
|
||||||
case ' ':
|
case ' ':
|
||||||
/* leading/trailing spaces not allowed */
|
/* leading/trailing spaces not allowed */
|
||||||
if (!i || i == AnsiName->Length-1 || AnsiName->Buffer[i+1] == '.') return FALSE;
|
if (!i || i == OemName->Length-1 || OemName->Buffer[i+1] == '.') return FALSE;
|
||||||
GotSpace = TRUE;
|
GotSpace = TRUE;
|
||||||
break;
|
break;
|
||||||
case '.':
|
case '.':
|
||||||
|
@ -277,7 +282,7 @@ RtlIsNameLegalDOS8Dot3(IN PCUNICODE_STRING UnicodeName,
|
||||||
Dot = i;
|
Dot = i;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (strchr(Illegal, AnsiName->Buffer[i])) return FALSE;
|
if (strchr(Illegal, OemName->Buffer[i])) return FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -286,13 +291,13 @@ RtlIsNameLegalDOS8Dot3(IN PCUNICODE_STRING UnicodeName,
|
||||||
*/
|
*/
|
||||||
if (Dot == -1)
|
if (Dot == -1)
|
||||||
{
|
{
|
||||||
if (AnsiName->Length > 8) return FALSE;
|
if (OemName->Length > 8) return FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Dot > 8 || (AnsiName->Length - Dot > 4) || Dot == AnsiName->Length - 1) return FALSE;
|
if (Dot > 8 || (OemName->Length - Dot > 4) || Dot == OemName->Length - 1) return FALSE;
|
||||||
}
|
}
|
||||||
if (SpacesFound) *SpacesFound = GotSpace;
|
if (NameContainsSpaces) *NameContainsSpaces = GotSpace;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue