From f9fd16f793470b4e36816110bef8376a211ec6c1 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Thu, 20 Nov 2008 20:24:10 +0000 Subject: [PATCH] - Upcase a search expression when calling RtlIsNameInExpression with case-insensitive option (a merge of 37263 from Pierre's branch with changed comments). svn path=/trunk/; revision=37490 --- reactos/drivers/filesystems/cdfs/dirctl.c | 14 ++++++++++++-- reactos/drivers/filesystems/cdfs/fcb.c | 16 ++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/reactos/drivers/filesystems/cdfs/dirctl.c b/reactos/drivers/filesystems/cdfs/dirctl.c index 10381f549bd..f2f39f8f2ed 100644 --- a/reactos/drivers/filesystems/cdfs/dirctl.c +++ b/reactos/drivers/filesystems/cdfs/dirctl.c @@ -166,6 +166,7 @@ CdfsFindFile(PDEVICE_EXTENSION DeviceExt, UNICODE_STRING TempString; UNICODE_STRING ShortName; UNICODE_STRING LongName; + UNICODE_STRING FileToFindUpcase; PVOID Block; NTSTATUS Status; ULONG len; @@ -263,6 +264,13 @@ CdfsFindFile(PDEVICE_EXTENSION DeviceExt, Record = (PDIR_RECORD)((ULONG_PTR)Record + Record->RecordLength); } + /* Upper case the expression for FsRtlIsNameInExpression */ + Status = RtlUpcaseUnicodeString(&FileToFindUpcase, FileToFind, TRUE); + if (!NT_SUCCESS(Status)) + { + return Status; + } + while(TRUE) { DPRINT("RecordLength %u ExtAttrRecordLength %u NameLength %u\n", @@ -307,8 +315,8 @@ CdfsFindFile(PDEVICE_EXTENSION DeviceExt, DPRINT("ShortName '%wZ'\n", &ShortName); - if (FsRtlIsNameInExpression(FileToFind, &LongName, TRUE, NULL) || - FsRtlIsNameInExpression(FileToFind, &ShortName, TRUE, NULL)) + if (FsRtlIsNameInExpression(&FileToFindUpcase, &LongName, TRUE, NULL) || + FsRtlIsNameInExpression(&FileToFindUpcase, &ShortName, TRUE, NULL)) { if (Parent && Parent->PathName) { @@ -347,6 +355,7 @@ CdfsFindFile(PDEVICE_EXTENSION DeviceExt, DPRINT("FindFile: new Pathname %S, new Objectname %S, DirIndex %d\n", Fcb->PathName, Fcb->ObjectName, DirIndex); + RtlFreeUnicodeString(&FileToFindUpcase); CcUnpinData(Context); return STATUS_SUCCESS; @@ -357,6 +366,7 @@ CdfsFindFile(PDEVICE_EXTENSION DeviceExt, DirIndex++; } + RtlFreeUnicodeString(&FileToFindUpcase); CcUnpinData(Context); if (pDirIndex) diff --git a/reactos/drivers/filesystems/cdfs/fcb.c b/reactos/drivers/filesystems/cdfs/fcb.c index f11eab4aa59..6dcf4c55352 100644 --- a/reactos/drivers/filesystems/cdfs/fcb.c +++ b/reactos/drivers/filesystems/cdfs/fcb.c @@ -464,6 +464,7 @@ CdfsDirFindFile(PDEVICE_EXTENSION DeviceExt, WCHAR ShortNameBuffer[13]; UNICODE_STRING ShortName; UNICODE_STRING LongName; + UNICODE_STRING FileToFindUpcase; BOOLEAN HasSpaces; GENERATE_NAME_CONTEXT NameContext; @@ -502,6 +503,14 @@ CdfsDirFindFile(PDEVICE_EXTENSION DeviceExt, Offset = 0; BlockOffset = 0; Record = (PDIR_RECORD)Block; + + /* Upper case the expression for FsRtlIsNameInExpression */ + Status = RtlUpcaseUnicodeString(&FileToFindUpcase, FileToFind, TRUE); + if (!NT_SUCCESS(Status)) + { + return Status; + } + while(TRUE) { if (Record->RecordLength == 0) @@ -543,8 +552,8 @@ CdfsDirFindFile(PDEVICE_EXTENSION DeviceExt, DPRINT("ShortName '%wZ'\n", &ShortName); - if (FsRtlIsNameInExpression(FileToFind, &LongName, TRUE, NULL) || - FsRtlIsNameInExpression(FileToFind, &ShortName, TRUE, NULL)) + if (FsRtlIsNameInExpression(&FileToFindUpcase, &LongName, TRUE, NULL) || + FsRtlIsNameInExpression(&FileToFindUpcase, &ShortName, TRUE, NULL)) { DPRINT("Match found, %S\n", Name); Status = CdfsMakeFCBFromDirEntry(DeviceExt, @@ -556,6 +565,7 @@ CdfsDirFindFile(PDEVICE_EXTENSION DeviceExt, Offset, FoundFCB); + RtlFreeUnicodeString(&FileToFindUpcase); CcUnpinData(Context); return(Status); @@ -578,6 +588,7 @@ CdfsDirFindFile(PDEVICE_EXTENSION DeviceExt, &Context, &Block)) { DPRINT("CcMapData() failed\n"); + RtlFreeUnicodeString(&FileToFindUpcase); return(STATUS_UNSUCCESSFUL); } Record = (PDIR_RECORD)((ULONG_PTR)Block + BlockOffset); @@ -587,6 +598,7 @@ CdfsDirFindFile(PDEVICE_EXTENSION DeviceExt, break; } + RtlFreeUnicodeString(&FileToFindUpcase); CcUnpinData(Context); return(STATUS_OBJECT_NAME_NOT_FOUND);