Author: cgutman
Date: Sat Jul 24 00:25:59 2010
New Revision: 48221
URL:
http://svn.reactos.org/svn/reactos?rev=48221&view=rev
Log:
- Fix epic naming fail (DhcpEnabled -> EnableDHCP
[DHCPCSVC]: Verify that the length is correct
[TCPIP]: Make sure DHCP is enabled before reading IP information
Modified:
trunk/reactos/dll/win32/dhcpcsvc/dhcp/adapter.c
trunk/reactos/dll/win32/netcfgx/netcfgx.c
trunk/reactos/drivers/network/tcpip/datalink/lan.c
Modified: trunk/reactos/dll/win32/dhcpcsvc/dhcp/adapter.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/dhcpcsvc/dhcp/ad…
==============================================================================
--- trunk/reactos/dll/win32/dhcpcsvc/dhcp/adapter.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/dhcpcsvc/dhcp/adapter.c [iso-8859-1] Sat Jul 24 00:25:59 2010
@@ -147,7 +147,7 @@
BOOL PrepareAdapterForService( PDHCP_ADAPTER Adapter ) {
HKEY AdapterKey;
- DWORD Error = ERROR_SUCCESS, DhcpEnabled;
+ DWORD Error = ERROR_SUCCESS, DhcpEnabled, Length;
Adapter->DhclientState.config = &Adapter->DhclientConfig;
strncpy(Adapter->DhclientInfo.name, (char*)Adapter->IfMib.bDescr,
@@ -156,9 +156,9 @@
AdapterKey = FindAdapterKey( Adapter );
if( AdapterKey )
{
- Error = RegQueryValueEx(AdapterKey, "DhcpEnabled", NULL, NULL,
(LPBYTE)&DhcpEnabled, NULL);
-
- if (Error != ERROR_SUCCESS)
+ Error = RegQueryValueEx(AdapterKey, "EnableDHCP", NULL, NULL,
(LPBYTE)&DhcpEnabled, &Length);
+
+ if (Error != ERROR_SUCCESS || Length != sizeof(DWORD))
DhcpEnabled = 1;
CloseHandle(AdapterKey);
Modified: trunk/reactos/dll/win32/netcfgx/netcfgx.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netcfgx/netcfgx.…
==============================================================================
--- trunk/reactos/dll/win32/netcfgx/netcfgx.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netcfgx/netcfgx.c [iso-8859-1] Sat Jul 24 00:25:59 2010
@@ -423,7 +423,7 @@
goto cleanup;
}
dwValue = 1;
- rc = RegSetValueExW(hKey, L"DhcpEnabled", 0, REG_DWORD, (const
BYTE*)&dwValue, sizeof(DWORD));
+ rc = RegSetValueExW(hKey, L"EnableDHCP", 0, REG_DWORD, (const
BYTE*)&dwValue, sizeof(DWORD));
if (rc != ERROR_SUCCESS)
{
DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc);
Modified: trunk/reactos/drivers/network/tcpip/datalink/lan.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/data…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/datalink/lan.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/datalink/lan.c [iso-8859-1] Sat Jul 24 00:25:59
2010
@@ -955,6 +955,7 @@
UNICODE_STRING IPAddress = RTL_CONSTANT_STRING(L"IPAddress");
UNICODE_STRING Netmask = RTL_CONSTANT_STRING(L"SubnetMask");
UNICODE_STRING Gateway = RTL_CONSTANT_STRING(L"DefaultGateway");
+ UNICODE_STRING EnableDhcp = RTL_CONSTANT_STRING(L"EnableDHCP");
UNICODE_STRING RegistryDataU;
ANSI_STRING RegistryDataA;
@@ -1033,75 +1034,89 @@
return FALSE;
}
- RegistryDataU.MaximumLength = 16 + sizeof(WCHAR);
- RegistryDataU.Buffer = (PWCHAR)KeyValueInfo->Data;
-
Status = ZwQueryValueKey(ParameterHandle,
- &IPAddress,
+ &EnableDhcp,
KeyValuePartialInformation,
KeyValueInfo,
- sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 16 *
sizeof(WCHAR),
+ sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(ULONG),
&Unused);
- if (NT_SUCCESS(Status))
+ if (NT_SUCCESS(Status) && KeyValueInfo->DataLength == sizeof(ULONG)
&& (*(PULONG)KeyValueInfo->Data) != 0)
{
- RegistryDataU.Length = KeyValueInfo->DataLength;
-
- RtlUnicodeStringToAnsiString(&RegistryDataA,
- &RegistryDataU,
- TRUE);
-
- AddrInitIPv4(&IF->Unicast, inet_addr(RegistryDataA.Buffer));
-
- RtlFreeAnsiString(&RegistryDataA);
-
+ RegistryDataU.MaximumLength = 16 + sizeof(WCHAR);
+ RegistryDataU.Buffer = (PWCHAR)KeyValueInfo->Data;
+
+ Status = ZwQueryValueKey(ParameterHandle,
+ &IPAddress,
+ KeyValuePartialInformation,
+ KeyValueInfo,
+ sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 16 *
sizeof(WCHAR),
+ &Unused);
+ if (NT_SUCCESS(Status))
+ {
+ RegistryDataU.Length = KeyValueInfo->DataLength;
+
+ RtlUnicodeStringToAnsiString(&RegistryDataA,
+ &RegistryDataU,
+ TRUE);
+
+ AddrInitIPv4(&IF->Unicast, inet_addr(RegistryDataA.Buffer));
+
+ RtlFreeAnsiString(&RegistryDataA);
+
+ }
+ else
+ {
+ IF->Unicast = DefaultMask;
+ }
+
+ Status = ZwQueryValueKey(ParameterHandle,
+ &Netmask,
+ KeyValuePartialInformation,
+ KeyValueInfo,
+ sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 16 *
sizeof(WCHAR),
+ &Unused);
+ if (NT_SUCCESS(Status))
+ {
+ RegistryDataU.Length = KeyValueInfo->DataLength;
+
+ RtlUnicodeStringToAnsiString(&RegistryDataA,
+ &RegistryDataU,
+ TRUE);
+
+ AddrInitIPv4(&IF->Netmask, inet_addr(RegistryDataA.Buffer));
+
+ RtlFreeAnsiString(&RegistryDataA);
+ }
+ else
+ {
+ IF->Netmask = DefaultMask;
+ }
+
+ Status = ZwQueryValueKey(ParameterHandle,
+ &Gateway,
+ KeyValuePartialInformation,
+ KeyValueInfo,
+ sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 16 *
sizeof(WCHAR),
+ &Unused);
+ if (NT_SUCCESS(Status))
+ {
+ RegistryDataU.Length = KeyValueInfo->DataLength;
+
+ RtlUnicodeStringToAnsiString(&RegistryDataA,
+ &RegistryDataU,
+ TRUE);
+
+ AddrInitIPv4(&Router, inet_addr(RegistryDataA.Buffer));
+
+ RtlFreeAnsiString(&RegistryDataA);
+
+ if (!AddrIsUnspecified(&Router)) RouterCreateRoute(&DefaultMask,
&DefaultMask, &Router, IF, 1);
+ }
}
else
{
IF->Unicast = DefaultMask;
- }
-
- Status = ZwQueryValueKey(ParameterHandle,
- &Netmask,
- KeyValuePartialInformation,
- KeyValueInfo,
- sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 16 *
sizeof(WCHAR),
- &Unused);
- if (NT_SUCCESS(Status))
- {
- RegistryDataU.Length = KeyValueInfo->DataLength;
-
- RtlUnicodeStringToAnsiString(&RegistryDataA,
- &RegistryDataU,
- TRUE);
-
- AddrInitIPv4(&IF->Netmask, inet_addr(RegistryDataA.Buffer));
-
- RtlFreeAnsiString(&RegistryDataA);
- }
- else
- {
IF->Netmask = DefaultMask;
- }
-
- Status = ZwQueryValueKey(ParameterHandle,
- &Gateway,
- KeyValuePartialInformation,
- KeyValueInfo,
- sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 16 *
sizeof(WCHAR),
- &Unused);
- if (NT_SUCCESS(Status))
- {
- RegistryDataU.Length = KeyValueInfo->DataLength;
-
- RtlUnicodeStringToAnsiString(&RegistryDataA,
- &RegistryDataU,
- TRUE);
-
- AddrInitIPv4(&Router, inet_addr(RegistryDataA.Buffer));
-
- RtlFreeAnsiString(&RegistryDataA);
-
- if (!AddrIsUnspecified(&Router)) RouterCreateRoute(&DefaultMask,
&DefaultMask, &Router, IF, 1);
}
ZwClose(ParameterHandle);