[ros-diffs] [rharabien] 52494: [FREELDR] - Allocate enough memory for unicode strings

rharabien at svn.reactos.org rharabien at svn.reactos.org
Thu Jun 30 18:55:45 UTC 2011


Author: rharabien
Date: Thu Jun 30 18:55:44 2011
New Revision: 52494

URL: http://svn.reactos.org/svn/reactos?rev=52494&view=rev
Log:
[FREELDR]
- Allocate enough memory for unicode strings

Modified:
    trunk/reactos/boot/freeldr/freeldr/windows/wlregistry.c

Modified: trunk/reactos/boot/freeldr/freeldr/windows/wlregistry.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windows/wlregistry.c?rev=52494&r1=52493&r2=52494&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/windows/wlregistry.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/windows/wlregistry.c [iso-8859-1] Thu Jun 30 18:55:44 2011
@@ -711,7 +711,7 @@
 {
 	PBOOT_DRIVER_LIST_ENTRY BootDriverEntry;
 	NTSTATUS Status;
-	ULONG PathLength;
+	USHORT PathLength;
 
 	BootDriverEntry = MmHeapAlloc(sizeof(BOOT_DRIVER_LIST_ENTRY));
 
@@ -726,10 +726,10 @@
 	if (ImagePath && (wcslen(ImagePath) > 0))
 	{
 		// Just copy ImagePath to the corresponding field in the structure
-		PathLength = wcslen(ImagePath) * sizeof(WCHAR);
+		PathLength = wcslen(ImagePath) * sizeof(WCHAR) + sizeof(UNICODE_NULL);
 
 		BootDriverEntry->FilePath.Length = 0;
-		BootDriverEntry->FilePath.MaximumLength = PathLength + sizeof(WCHAR);
+		BootDriverEntry->FilePath.MaximumLength = PathLength;
 		BootDriverEntry->FilePath.Buffer = MmHeapAlloc(PathLength);
 
 		if (!BootDriverEntry->FilePath.Buffer)
@@ -751,7 +751,7 @@
 		// we have to construct ImagePath ourselves
 		PathLength = wcslen(ServiceName)*sizeof(WCHAR) + sizeof(L"system32\\drivers\\.sys");
 		BootDriverEntry->FilePath.Length = 0;
-		BootDriverEntry->FilePath.MaximumLength = PathLength+sizeof(WCHAR);
+		BootDriverEntry->FilePath.MaximumLength = PathLength;
 		BootDriverEntry->FilePath.Buffer = MmHeapAlloc(PathLength);
 
 		if (!BootDriverEntry->FilePath.Buffer)
@@ -786,9 +786,9 @@
 	}
 
 	// Add registry path
-	PathLength = (wcslen(RegistryPath)+wcslen(ServiceName))*sizeof(WCHAR);
+	PathLength = (wcslen(RegistryPath) + wcslen(ServiceName))*sizeof(WCHAR) + sizeof(UNICODE_NULL);
 	BootDriverEntry->RegistryPath.Length = 0;
-	BootDriverEntry->RegistryPath.MaximumLength = PathLength;//+sizeof(WCHAR);
+	BootDriverEntry->RegistryPath.MaximumLength = PathLength;
 	BootDriverEntry->RegistryPath.Buffer = MmHeapAlloc(PathLength);
 	if (!BootDriverEntry->RegistryPath.Buffer)
 		return FALSE;




More information about the Ros-diffs mailing list