- Fix KSPROPERTY_PIN_CATEGORY handler when no category is provided
- Fix KSPROPERTY_PIN_NAME handler when there is no name provided. Use fallback pin category. If there is no category provided, fail with correct error code
- Fix KSPROPERTY_TOPOLOGY_NAME handler by checking if there is a node name provided. If not use node type as fallback.
- Return correct error code when property request id is out of bounds

svn path=/trunk/; revision=49199
This commit is contained in:
Johannes Anderwald 2010-10-18 22:21:00 +00:00
parent 54374ca72e
commit 619ab27e1d
2 changed files with 65 additions and 11 deletions

View file

@ -330,6 +330,7 @@ KspPinPropertyHandler(
NTSTATUS Status = STATUS_NOT_SUPPORTED;
ULONG Count;
const PKSDATARANGE* DataRanges;
LPGUID Guid;
IoStack = IoGetCurrentIrpStackLocation(Irp);
Buffer = Irp->UserBuffer;
@ -509,48 +510,77 @@ KspPinPropertyHandler(
case KSPROPERTY_PIN_CATEGORY:
if (!Descriptor->Category)
{
/* no pin category */
return STATUS_NOT_FOUND;
}
/* check size */
Size = sizeof(GUID);
if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < Size)
{
/* buffer too small */
Irp->IoStatus.Information = Size;
Status = STATUS_BUFFER_TOO_SMALL;
break;
}
if (Descriptor->Category)
{
RtlMoveMemory(Buffer, Descriptor->Category, sizeof(GUID));
}
/* copy category guid */
RtlMoveMemory(Buffer, Descriptor->Category, sizeof(GUID));
/* save result */
Status = STATUS_SUCCESS;
Irp->IoStatus.Information = Size;
break;
case KSPROPERTY_PIN_NAME:
if (!Descriptor->Name)
if (Descriptor->Name)
{
Irp->IoStatus.Information = 0;
Status = STATUS_SUCCESS;
break;
/* use pin name */
Guid = (LPGUID)Descriptor->Name;
}
else
{
/* use pin category as fallback */
Guid = (LPGUID)Descriptor->Category;
}
Status = KspReadMediaCategory((LPGUID)Descriptor->Name, &KeyInfo);
if (!Guid)
{
/* no friendly name available */
return STATUS_NOT_FOUND;
}
/* read friendly name category name */
Status = KspReadMediaCategory(Guid, &KeyInfo);
if (!NT_SUCCESS(Status))
{
/* failed to read category */
Irp->IoStatus.Information = 0;
break;
}
/* store required length */
Irp->IoStatus.Information = KeyInfo->DataLength + sizeof(WCHAR);
/* check if buffer is too small */
if (KeyInfo->DataLength + sizeof(WCHAR) > IoStack->Parameters.DeviceIoControl.OutputBufferLength)
{
/* buffer too small */
Status = STATUS_BUFFER_OVERFLOW;
FreeItem(KeyInfo);
break;
}
/* copy result */
RtlMoveMemory(Irp->UserBuffer, &KeyInfo->Data, KeyInfo->DataLength);
/* null terminate name */
((LPWSTR)Irp->UserBuffer)[KeyInfo->DataLength / sizeof(WCHAR)] = L'\0';
/* free key info */
FreeItem(KeyInfo);
break;
case KSPROPERTY_PIN_PROPOSEDATAFORMAT:

View file

@ -151,6 +151,7 @@ KsTopologyPropertyHandler(
PIO_STACK_LOCATION IoStack;
NTSTATUS Status;
PKEY_VALUE_PARTIAL_INFORMATION KeyInfo;
LPGUID Guid;
IoStack = IoGetCurrentIrpStackLocation(Irp);
@ -177,37 +178,60 @@ KsTopologyPropertyHandler(
case KSPROPERTY_TOPOLOGY_NAME:
Node = (KSP_NODE*)Property;
/* check for invalid node id */
if (Node->NodeId >= Topology->TopologyNodesCount)
{
/* invalid node id */
Irp->IoStatus.Information = 0;
Status = STATUS_INVALID_PARAMETER;
break;
}
Status = KspReadMediaCategory((LPGUID)&Topology->TopologyNodesNames[Node->NodeId], &KeyInfo);
/* check if there is a name supplied */
if (!IsEqualGUIDAligned(&Topology->TopologyNodesNames[Node->NodeId], &GUID_NULL))
{
/* node name has been supplied */
Guid = (LPGUID)&Topology->TopologyNodesNames[Node->NodeId];
}
else
{
/* fallback to topology node type */
Guid = (LPGUID)&Topology->TopologyNodes[Node->NodeId];
}
/* read topology node name */
Status = KspReadMediaCategory(Guid, &KeyInfo);
if (!NT_SUCCESS(Status))
{
Irp->IoStatus.Information = 0;
break;
}
/* store result size */
Irp->IoStatus.Information = KeyInfo->DataLength + sizeof(WCHAR);
/* check for buffer overflow */
if (KeyInfo->DataLength + sizeof(WCHAR) > IoStack->Parameters.DeviceIoControl.OutputBufferLength)
{
/* buffer too small */
Status = STATUS_BUFFER_OVERFLOW;
FreeItem(KeyInfo);
break;
}
/* copy result buffer */
RtlMoveMemory(Irp->UserBuffer, &KeyInfo->Data, KeyInfo->DataLength);
/* zero terminate it */
((LPWSTR)Irp->UserBuffer)[KeyInfo->DataLength / sizeof(WCHAR)] = L'\0';
/* free key info */
FreeItem(KeyInfo);
break;
default:
Irp->IoStatus.Information = 0;
Status = STATUS_NOT_IMPLEMENTED;
Status = STATUS_NOT_FOUND;
}