Author: hpoussin Date: Thu Dec 27 21:53:24 2007 New Revision: 31466
URL: http://svn.reactos.org/svn/reactos?rev=31466&view=rev Log: NULL terminate string before sending it
Modified: trunk/reactos/ntoskrnl/io/pnpmgr/plugplay.c
Modified: trunk/reactos/ntoskrnl/io/pnpmgr/plugplay.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/plugplay... ============================================================================== --- trunk/reactos/ntoskrnl/io/pnpmgr/plugplay.c (original) +++ trunk/reactos/ntoskrnl/io/pnpmgr/plugplay.c Thu Dec 27 21:53:24 2007 @@ -49,26 +49,36 @@ PUNICODE_STRING DeviceIds) { PPNP_EVENT_ENTRY EventEntry; + UNICODE_STRING Copy; ULONG TotalSize; - + NTSTATUS Status; + + ASSERT(DeviceIds); + + /* Allocate a big enough buffer */ + Copy.Length = 0; + Copy.MaximumLength = DeviceIds->Length + sizeof(UNICODE_NULL); TotalSize = FIELD_OFFSET(PLUGPLAY_EVENT_BLOCK, TargetDevice.DeviceIds) + - DeviceIds->MaximumLength; + Copy.MaximumLength;
EventEntry = ExAllocatePool(NonPagedPool, TotalSize + FIELD_OFFSET(PNP_EVENT_ENTRY, Event)); - if (EventEntry == NULL) + if (!EventEntry) return STATUS_INSUFFICIENT_RESOURCES;
- memcpy(&EventEntry->Event.EventGuid, - Guid, - sizeof(GUID)); + /* Fill the buffer with the event GUID */ + RtlCopyMemory(&EventEntry->Event.EventGuid, + Guid, + sizeof(GUID)); EventEntry->Event.EventCategory = TargetDeviceChangeEvent; EventEntry->Event.TotalSize = TotalSize;
- memcpy(&EventEntry->Event.TargetDevice.DeviceIds, - DeviceIds->Buffer, - DeviceIds->MaximumLength); + /* Fill the device id */ + Copy.Buffer = EventEntry->Event.TargetDevice.DeviceIds; + Status = RtlAppendUnicodeStringToString(&Copy, DeviceIds); + if (!NT_SUCCESS(Status)) + return Status;
InsertHeadList(&IopPnpEventQueueHead, &EventEntry->ListEntry);