- 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
This commit is contained in:
Aleksey Bragin
2008-11-20 20:24:10 +00:00
parent 783e8e1be3
commit f9fd16f793
2 changed files with 26 additions and 4 deletions

View File

@@ -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)

View File

@@ -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);