mirror of
https://github.com/reactos/reactos.git
synced 2024-10-08 10:24:06 +00:00
[MOUNTMGR]
- Fix IsDriveLetter. CID 1206760. svn path=/trunk/; revision=64798
This commit is contained in:
parent
e383d6c605
commit
71451cf5dd
|
@ -923,27 +923,35 @@ DeleteSymbolicLinkNameFromMemory(IN PDEVICE_EXTENSION DeviceExtension,
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
IsDriveLetter(PUNICODE_STRING SymbolicName)
|
IsDriveLetter(PUNICODE_STRING SymbolicName)
|
||||||
{
|
{
|
||||||
WCHAR Letter;
|
WCHAR Letter, Colon;
|
||||||
BOOLEAN Result = FALSE;
|
|
||||||
|
|
||||||
/* We must have a precise length */
|
/* We must have a precise length */
|
||||||
if (SymbolicName->Length != sizeof(DosDevices.Buffer) + 2 * sizeof(WCHAR))
|
if (SymbolicName->Length != DosDevices.Length + 2 * sizeof(WCHAR))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if len is correct */
|
/* Must start with the DosDevices prefix */
|
||||||
Letter = SymbolicName->Buffer[sizeof(DosDevices.Buffer) / sizeof(WCHAR)];
|
if (!RtlPrefixUnicodeString(&DosDevices, SymbolicName, TRUE))
|
||||||
if (((Letter >= L'A' && Letter <= L'Z') || Letter == (WCHAR)-1) &&
|
|
||||||
SymbolicName->Buffer[(sizeof(DosDevices.Buffer) + sizeof(WCHAR)) / sizeof (WCHAR)] == L':')
|
|
||||||
{
|
{
|
||||||
/* In case it's not a normal drive letter, check differently */
|
return FALSE;
|
||||||
SymbolicName->Length = sizeof(DosDevices.Buffer);
|
|
||||||
Result = RtlEqualUnicodeString(SymbolicName, &DosDevices, TRUE);
|
|
||||||
SymbolicName->Length = sizeof(DosDevices.Buffer) + 2 * sizeof(WCHAR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result;
|
/* Check if letter is correct */
|
||||||
|
Letter = SymbolicName->Buffer[DosDevices.Length / sizeof(WCHAR)];
|
||||||
|
if ((Letter < L'A' || Letter > L'Z') && Letter != (WCHAR)-1)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* And finally it must end with a colon */
|
||||||
|
Colon = SymbolicName->Buffer[DosDevices.Length / sizeof(WCHAR) + 1];
|
||||||
|
if (Colon != L':')
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue