NULL terminate string before sending it

svn path=/trunk/; revision=31466
This commit is contained in:
Hervé Poussineau 2007-12-27 18:53:24 +00:00
parent 8dd1e30e97
commit fe052d8d46

View file

@ -49,26 +49,36 @@ IopQueueTargetDeviceEvent(const GUID *Guid,
PUNICODE_STRING DeviceIds) PUNICODE_STRING DeviceIds)
{ {
PPNP_EVENT_ENTRY EventEntry; PPNP_EVENT_ENTRY EventEntry;
UNICODE_STRING Copy;
ULONG TotalSize; ULONG TotalSize;
NTSTATUS Status;
ASSERT(DeviceIds);
/* Allocate a big enough buffer */
Copy.Length = 0;
Copy.MaximumLength = DeviceIds->Length + sizeof(UNICODE_NULL);
TotalSize = TotalSize =
FIELD_OFFSET(PLUGPLAY_EVENT_BLOCK, TargetDevice.DeviceIds) + FIELD_OFFSET(PLUGPLAY_EVENT_BLOCK, TargetDevice.DeviceIds) +
DeviceIds->MaximumLength; Copy.MaximumLength;
EventEntry = ExAllocatePool(NonPagedPool, EventEntry = ExAllocatePool(NonPagedPool,
TotalSize + FIELD_OFFSET(PNP_EVENT_ENTRY, Event)); TotalSize + FIELD_OFFSET(PNP_EVENT_ENTRY, Event));
if (EventEntry == NULL) if (!EventEntry)
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
memcpy(&EventEntry->Event.EventGuid, /* Fill the buffer with the event GUID */
Guid, RtlCopyMemory(&EventEntry->Event.EventGuid,
sizeof(GUID)); Guid,
sizeof(GUID));
EventEntry->Event.EventCategory = TargetDeviceChangeEvent; EventEntry->Event.EventCategory = TargetDeviceChangeEvent;
EventEntry->Event.TotalSize = TotalSize; EventEntry->Event.TotalSize = TotalSize;
memcpy(&EventEntry->Event.TargetDevice.DeviceIds, /* Fill the device id */
DeviceIds->Buffer, Copy.Buffer = EventEntry->Event.TargetDevice.DeviceIds;
DeviceIds->MaximumLength); Status = RtlAppendUnicodeStringToString(&Copy, DeviceIds);
if (!NT_SUCCESS(Status))
return Status;
InsertHeadList(&IopPnpEventQueueHead, InsertHeadList(&IopPnpEventQueueHead,
&EventEntry->ListEntry); &EventEntry->ListEntry);