mirror of
https://github.com/reactos/reactos.git
synced 2024-07-10 06:35:06 +00:00
[KS]
Pass a PUNICODE_STRING instead of a LPWSTR (and unused BufferSize) to FindMatchingCreateItem(), make use of the Length parameter instead of trusting on NULL termination when searching for path separators. svn path=/trunk/; revision=58065
This commit is contained in:
parent
93be7a7d03
commit
803933e000
|
@ -218,7 +218,7 @@ IKsDevice_fnCheckIoCapability(
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static IKsDeviceVtbl vt_IKsDevice =
|
static IKsDeviceVtbl vt_IKsDevice =
|
||||||
{
|
{
|
||||||
IKsDevice_fnQueryInterface,
|
IKsDevice_fnQueryInterface,
|
||||||
IKsDevice_fnAddRef,
|
IKsDevice_fnAddRef,
|
||||||
|
@ -631,12 +631,16 @@ IKsDevice_Create(
|
||||||
ASSERT(ObjectHeader);
|
ASSERT(ObjectHeader);
|
||||||
|
|
||||||
/* find a matching a create item */
|
/* find a matching a create item */
|
||||||
Status = FindMatchingCreateItem(&ObjectHeader->ItemList, IoStack->FileObject->FileName.Length, IoStack->FileObject->FileName.Buffer, &CreateItemEntry);
|
Status = FindMatchingCreateItem(&ObjectHeader->ItemList,
|
||||||
|
&IoStack->FileObject->FileName,
|
||||||
|
&CreateItemEntry);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* request to create a filter */
|
/* request to create a filter */
|
||||||
Status = FindMatchingCreateItem(&DeviceHeader->ItemList, IoStack->FileObject->FileName.Length, IoStack->FileObject->FileName.Buffer, &CreateItemEntry);
|
Status = FindMatchingCreateItem(&DeviceHeader->ItemList,
|
||||||
|
&IoStack->FileObject->FileName,
|
||||||
|
&CreateItemEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
|
|
|
@ -1175,7 +1175,7 @@ KsDefaultDeviceIoCompletion(
|
||||||
/* get current irp stack */
|
/* get current irp stack */
|
||||||
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
|
||||||
if (IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_PROPERTY &&
|
if (IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_PROPERTY &&
|
||||||
IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_METHOD &&
|
IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_METHOD &&
|
||||||
IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_PROPERTY)
|
IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_PROPERTY)
|
||||||
{
|
{
|
||||||
|
@ -1744,41 +1744,53 @@ KsCancelRoutine(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
FindMatchingCreateItem(
|
FindMatchingCreateItem(
|
||||||
PLIST_ENTRY ListHead,
|
PLIST_ENTRY ListHead,
|
||||||
ULONG BufferSize,
|
PUNICODE_STRING String,
|
||||||
LPWSTR Buffer,
|
|
||||||
OUT PCREATE_ITEM_ENTRY *OutCreateItem)
|
OUT PCREATE_ITEM_ENTRY *OutCreateItem)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY Entry;
|
PLIST_ENTRY Entry;
|
||||||
PCREATE_ITEM_ENTRY CreateItemEntry;
|
PCREATE_ITEM_ENTRY CreateItemEntry;
|
||||||
UNICODE_STRING RefString;
|
UNICODE_STRING RefString;
|
||||||
LPWSTR pStr;
|
LPWSTR pStr;
|
||||||
|
ULONG Count;
|
||||||
|
|
||||||
/* get terminator */
|
/* Copy the input string */
|
||||||
pStr = wcschr(Buffer, L'\\');
|
RefString = *String;
|
||||||
|
|
||||||
/* sanity check */
|
/* Check if the string starts with a backslash */
|
||||||
ASSERT(pStr != NULL);
|
if (String->Buffer[0] == L'\\')
|
||||||
|
|
||||||
if (pStr == Buffer)
|
|
||||||
{
|
{
|
||||||
// skip slash
|
/* Skip backslash */
|
||||||
RtlInitUnicodeString(&RefString, ++pStr);
|
RefString.Buffer++;
|
||||||
|
RefString.Length -= sizeof(WCHAR);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* get terminator */
|
||||||
|
pStr = String->Buffer;
|
||||||
|
Count = String->Length / sizeof(WCHAR);
|
||||||
|
while ((Count > 0) && (*pStr != L'\\'))
|
||||||
|
{
|
||||||
|
pStr++;
|
||||||
|
Count--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* sanity check */
|
||||||
|
ASSERT(Count != 0);
|
||||||
|
|
||||||
// request is for pin / node / allocator
|
// request is for pin / node / allocator
|
||||||
RefString.Buffer = Buffer;
|
RefString.Length = (USHORT)((PCHAR)pStr - (PCHAR)String->Buffer);
|
||||||
RefString.Length = BufferSize = RefString.MaximumLength = ((ULONG_PTR)pStr - (ULONG_PTR)Buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* point to first entry */
|
/* point to first entry */
|
||||||
Entry = ListHead->Flink;
|
Entry = ListHead->Flink;
|
||||||
|
|
||||||
/* loop all device items */
|
/* loop all device items */
|
||||||
while(Entry != ListHead)
|
while (Entry != ListHead)
|
||||||
{
|
{
|
||||||
/* get create item entry */
|
/* get create item entry */
|
||||||
CreateItemEntry = (PCREATE_ITEM_ENTRY)CONTAINING_RECORD(Entry, CREATE_ITEM_ENTRY, Entry);
|
CreateItemEntry = (PCREATE_ITEM_ENTRY)CONTAINING_RECORD(Entry,
|
||||||
|
CREATE_ITEM_ENTRY,
|
||||||
|
Entry);
|
||||||
|
|
||||||
ASSERT(CreateItemEntry->CreateItem);
|
ASSERT(CreateItemEntry->CreateItem);
|
||||||
|
|
||||||
|
@ -1796,10 +1808,11 @@ FindMatchingCreateItem(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("CreateItem %S Length %u Request %wZ %u\n", CreateItemEntry->CreateItem->ObjectClass.Buffer,
|
DPRINT("CreateItem %S Length %u Request %wZ %u\n",
|
||||||
CreateItemEntry->CreateItem->ObjectClass.Length,
|
CreateItemEntry->CreateItem->ObjectClass.Buffer,
|
||||||
&RefString,
|
CreateItemEntry->CreateItem->ObjectClass.Length,
|
||||||
RefString.Length);
|
&RefString,
|
||||||
|
RefString.Length);
|
||||||
|
|
||||||
if (CreateItemEntry->CreateItem->ObjectClass.Length > RefString.Length)
|
if (CreateItemEntry->CreateItem->ObjectClass.Length > RefString.Length)
|
||||||
{
|
{
|
||||||
|
@ -1809,7 +1822,9 @@ FindMatchingCreateItem(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now check if the object class is the same */
|
/* now check if the object class is the same */
|
||||||
if (!RtlCompareUnicodeString(&CreateItemEntry->CreateItem->ObjectClass, &RefString, TRUE))
|
if (!RtlCompareUnicodeString(&CreateItemEntry->CreateItem->ObjectClass,
|
||||||
|
&RefString,
|
||||||
|
TRUE))
|
||||||
{
|
{
|
||||||
/* found matching create item */
|
/* found matching create item */
|
||||||
*OutCreateItem = CreateItemEntry;
|
*OutCreateItem = CreateItemEntry;
|
||||||
|
@ -1865,12 +1880,16 @@ KspCreate(
|
||||||
ASSERT(ObjectHeader);
|
ASSERT(ObjectHeader);
|
||||||
|
|
||||||
/* find a matching a create item */
|
/* find a matching a create item */
|
||||||
Status = FindMatchingCreateItem(&ObjectHeader->ItemList, IoStack->FileObject->FileName.Length, IoStack->FileObject->FileName.Buffer, &CreateItemEntry);
|
Status = FindMatchingCreateItem(&ObjectHeader->ItemList,
|
||||||
|
&IoStack->FileObject->FileName,
|
||||||
|
&CreateItemEntry);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* request to create a filter */
|
/* request to create a filter */
|
||||||
Status = FindMatchingCreateItem(&DeviceHeader->ItemList, IoStack->FileObject->FileName.Length, IoStack->FileObject->FileName.Buffer, &CreateItemEntry);
|
Status = FindMatchingCreateItem(&DeviceHeader->ItemList,
|
||||||
|
&IoStack->FileObject->FileName,
|
||||||
|
&CreateItemEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
|
|
|
@ -106,8 +106,7 @@ KspPinPropertyHandler(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
FindMatchingCreateItem(
|
FindMatchingCreateItem(
|
||||||
PLIST_ENTRY ListHead,
|
PLIST_ENTRY ListHead,
|
||||||
ULONG BufferSize,
|
PUNICODE_STRING String,
|
||||||
LPWSTR Buffer,
|
|
||||||
OUT PCREATE_ITEM_ENTRY *OutCreateItem);
|
OUT PCREATE_ITEM_ENTRY *OutCreateItem);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
|
Loading…
Reference in a new issue