mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 13:21:39 +00:00
NULL terminate string before sending it
svn path=/trunk/; revision=31466
This commit is contained in:
parent
8dd1e30e97
commit
fe052d8d46
1 changed files with 18 additions and 8 deletions
|
@ -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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue