- Use correct buffer size in KspStartBusDevice. Spotted by Víctor Martínez
- Avoid wcscpy in kernel mode while we're at it

svn path=/trunk/; revision=63778
This commit is contained in:
Thomas Faber 2014-07-30 07:50:28 +00:00
parent 602fd06fa1
commit fd1986de3a
2 changed files with 6 additions and 3 deletions

View file

@ -7,6 +7,7 @@
#include <portcls.h> #include <portcls.h>
#include <kcom.h> #include <kcom.h>
#include <pseh/pseh2.h> #include <pseh/pseh2.h>
#include <ntstrsafe.h>
#include "ksiface.h" #include "ksiface.h"
#include "kstypes.h" #include "kstypes.h"

View file

@ -757,12 +757,13 @@ KspStartBusDevice(
NTSTATUS Status; NTSTATUS Status;
ULONG ResultLength; ULONG ResultLength;
LPWSTR Name; LPWSTR Name;
ULONG NameLength;
PBUS_DEVICE_ENTRY DeviceEntry; PBUS_DEVICE_ENTRY DeviceEntry;
/* FIXME handle pending remove */ /* FIXME handle pending remove */
/* get full device name */ /* get full device name */
Status = IoGetDeviceProperty(DeviceObject, DevicePropertyPhysicalDeviceObjectName, sizeof(PDOName), (PVOID)PDOName, &ResultLength); Status = IoGetDeviceProperty(DeviceObject, DevicePropertyPhysicalDeviceObjectName, sizeof(PDOName), PDOName, &ResultLength);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
@ -771,7 +772,8 @@ KspStartBusDevice(
} }
/* allocate device name buffer */ /* allocate device name buffer */
Name = AllocateItem(NonPagedPool, (ResultLength + 1) * sizeof(WCHAR)); NameLength = ResultLength + sizeof(UNICODE_NULL);
Name = AllocateItem(NonPagedPool, NameLength);
if (!Name) if (!Name)
{ {
/* no memory */ /* no memory */
@ -779,7 +781,7 @@ KspStartBusDevice(
} }
/* copy name */ /* copy name */
wcscpy(Name, PDOName); NT_VERIFY(NT_SUCCESS(RtlStringCbCopyW(Name, NameLength, PDOName)));
/* TODO: time stamp creation time */ /* TODO: time stamp creation time */