From 71451cf5dd3426596838ec8b17bffba77600c5c4 Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Sat, 18 Oct 2014 10:11:02 +0000 Subject: [PATCH] [MOUNTMGR] - Fix IsDriveLetter. CID 1206760. svn path=/trunk/; revision=64798 --- reactos/drivers/filters/mountmgr/symlink.c | 32 ++++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/reactos/drivers/filters/mountmgr/symlink.c b/reactos/drivers/filters/mountmgr/symlink.c index 80c5b00873e..3fc954dfdbe 100644 --- a/reactos/drivers/filters/mountmgr/symlink.c +++ b/reactos/drivers/filters/mountmgr/symlink.c @@ -923,27 +923,35 @@ DeleteSymbolicLinkNameFromMemory(IN PDEVICE_EXTENSION DeviceExtension, BOOLEAN IsDriveLetter(PUNICODE_STRING SymbolicName) { - WCHAR Letter; - BOOLEAN Result = FALSE; + WCHAR Letter, Colon; /* 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; } - /* Check if len is correct */ - Letter = SymbolicName->Buffer[sizeof(DosDevices.Buffer) / sizeof(WCHAR)]; - if (((Letter >= L'A' && Letter <= L'Z') || Letter == (WCHAR)-1) && - SymbolicName->Buffer[(sizeof(DosDevices.Buffer) + sizeof(WCHAR)) / sizeof (WCHAR)] == L':') + /* Must start with the DosDevices prefix */ + if (!RtlPrefixUnicodeString(&DosDevices, SymbolicName, TRUE)) { - /* In case it's not a normal drive letter, check differently */ - SymbolicName->Length = sizeof(DosDevices.Buffer); - Result = RtlEqualUnicodeString(SymbolicName, &DosDevices, TRUE); - SymbolicName->Length = sizeof(DosDevices.Buffer) + 2 * sizeof(WCHAR); + return FALSE; } - 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; } /*