- Fix string length calculation

svn path=/trunk/; revision=53250
This commit is contained in:
Cameron Gutman 2011-08-15 03:20:17 +00:00
parent a92715a798
commit 3efa379202

View file

@ -492,16 +492,12 @@ HalpQueryIdPdo(IN PDEVICE_OBJECT DeviceObject,
/* Unknown */ /* Unknown */
return STATUS_NOT_SUPPORTED; return STATUS_NOT_SUPPORTED;
} }
/* Static length */
Length = 32;
break; break;
case BusQueryInstanceID: case BusQueryInstanceID:
/* And our instance ID */ /* And our instance ID */
Id = L"0"; Id = L"0";
Length = sizeof(L"0") + sizeof(UNICODE_NULL);
break; break;
case BusQueryCompatibleIDs: case BusQueryCompatibleIDs:
@ -511,6 +507,9 @@ HalpQueryIdPdo(IN PDEVICE_OBJECT DeviceObject,
return STATUS_NOT_SUPPORTED; return STATUS_NOT_SUPPORTED;
} }
/* Calculate the length */
Length = (wcslen(Id) * sizeof(WCHAR)) + sizeof(UNICODE_NULL);
/* Allocate the buffer */ /* Allocate the buffer */
Buffer = ExAllocatePoolWithTag(PagedPool, Buffer = ExAllocatePoolWithTag(PagedPool,
Length + sizeof(UNICODE_NULL), Length + sizeof(UNICODE_NULL),
@ -556,14 +555,12 @@ HalpQueryIdFdo(IN PDEVICE_OBJECT DeviceObject,
/* This is our hardware ID */ /* This is our hardware ID */
Id = HalHardwareIdString; Id = HalHardwareIdString;
Length = wcslen(HalHardwareIdString) + sizeof(UNICODE_NULL);
break; break;
case BusQueryInstanceID: case BusQueryInstanceID:
/* And our instance ID */ /* And our instance ID */
Id = L"0"; Id = L"0";
Length = sizeof(L"0") + sizeof(UNICODE_NULL);
break; break;
default: default:
@ -572,6 +569,9 @@ HalpQueryIdFdo(IN PDEVICE_OBJECT DeviceObject,
return STATUS_NOT_SUPPORTED; return STATUS_NOT_SUPPORTED;
} }
/* Calculate the length */
Length = (wcslen(Id) * sizeof(WCHAR)) + sizeof(UNICODE_NULL);
/* Allocate the buffer */ /* Allocate the buffer */
Buffer = ExAllocatePoolWithTag(PagedPool, Buffer = ExAllocatePoolWithTag(PagedPool,
Length + sizeof(UNICODE_NULL), Length + sizeof(UNICODE_NULL),