[KS]
authorThomas Faber <thomas.faber@reactos.org>
Wed, 30 Jul 2014 07:50:28 +0000 (07:50 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Wed, 30 Jul 2014 07:50:28 +0000 (07:50 +0000)
- 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

reactos/drivers/ksfilter/ks/precomp.h
reactos/drivers/ksfilter/ks/swenum.c

index 09f3516..738176c 100644 (file)
@@ -7,6 +7,7 @@
 #include <portcls.h>
 #include <kcom.h>
 #include <pseh/pseh2.h>
 #include <portcls.h>
 #include <kcom.h>
 #include <pseh/pseh2.h>
+#include <ntstrsafe.h>
 
 #include "ksiface.h"
 #include "kstypes.h"
 
 #include "ksiface.h"
 #include "kstypes.h"
index 93dbb41..119d13d 100644 (file)
@@ -757,12 +757,13 @@ KspStartBusDevice(
     NTSTATUS Status;
     ULONG ResultLength;
     LPWSTR Name;
     NTSTATUS Status;
     ULONG ResultLength;
     LPWSTR Name;
+    ULONG NameLength;
     PBUS_DEVICE_ENTRY DeviceEntry;
 
     /* FIXME handle pending remove */
 
     /* get full device name */
     PBUS_DEVICE_ENTRY DeviceEntry;
 
     /* FIXME handle pending remove */
 
     /* 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)
     {
         /* no memory */
     if (!Name)
     {
         /* 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 */