Allocate enough memory for Value (problem was spotted by Pigglesworth)
authorColin Finck <colin@reactos.org>
Sat, 18 Oct 2008 22:22:09 +0000 (22:22 +0000)
committerColin Finck <colin@reactos.org>
Sat, 18 Oct 2008 22:22:09 +0000 (22:22 +0000)
This problem was revealed by r36797 (thanks to aicom, elhoir, Lone_Rifle and vicmarcal for the help with regression testing)

Fixes ipconfig, ping and other network apps crashing with a buffer overflow.

svn path=/trunk/; revision=36816

reactos/dll/win32/iphlpapi/registry.c

index 6875d03..2421b1c 100644 (file)
@@ -50,7 +50,7 @@ PWCHAR GetNthChildKeyName( HANDLE RegHandle, DWORD n ) {
   }
 
   ValueLen = MaxAdapterName;
   }
 
   ValueLen = MaxAdapterName;
-  Value = (PWCHAR)HeapAlloc( GetProcessHeap(), 0, MaxAdapterName );
+  Value = (PWCHAR)HeapAlloc( GetProcessHeap(), 0, MaxAdapterName * sizeof(WCHAR) );
   Status = RegEnumKeyExW( RegHandle, n, Value, &ValueLen,
                          NULL, NULL, NULL, NULL );
   if (Status != ERROR_SUCCESS)
   Status = RegEnumKeyExW( RegHandle, n, Value, &ValueLen,
                          NULL, NULL, NULL, NULL );
   if (Status != ERROR_SUCCESS)