Author: cgutman
Date: Mon Aug 23 21:11:01 2010
New Revision: 48611
URL:
http://svn.reactos.org/svn/reactos?rev=48611&view=rev
Log:
- Revert the change from REG_SZ to REG_MULTI_SZ because it turns out that Windows does it
this same way (research fail?)
Modified:
trunk/reactos/dll/win32/dhcpcsvc/dhcp/dhclient.c
trunk/reactos/dll/win32/iphlpapi/resinfo_reactos.c
Modified: trunk/reactos/dll/win32/dhcpcsvc/dhcp/dhclient.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/dhcpcsvc/dhcp/dh…
==============================================================================
--- trunk/reactos/dll/win32/dhcpcsvc/dhcp/dhclient.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/dhcpcsvc/dhcp/dhclient.c [iso-8859-1] Mon Aug 23 21:11:01
2010
@@ -507,25 +507,24 @@
char *nsbuf;
int i, addrs =
new_lease->options[DHO_DOMAIN_NAME_SERVERS].len / sizeof(ULONG);
- int len = 0;
-
- nsbuf = malloc( addrs * sizeof(IP_ADDRESS_STRING) + 1 );
+
+ nsbuf = malloc( addrs * sizeof(IP_ADDRESS_STRING) );
if( nsbuf) {
- memset(nsbuf, 0, addrs * sizeof(IP_ADDRESS_STRING) + 1);
+ nsbuf[0] = 0;
for( i = 0; i < addrs; i++ ) {
nameserver.len = sizeof(ULONG);
memcpy( nameserver.iabuf,
new_lease->options[DHO_DOMAIN_NAME_SERVERS].data +
(i * sizeof(ULONG)), sizeof(ULONG) );
strcat( nsbuf, piaddr(nameserver) );
- len += strlen(nsbuf) + 1;
+ if( i != addrs-1 ) strcat( nsbuf, "," );
}
DH_DbgPrint(MID_TRACE,("Setting DhcpNameserver: %s\n", nsbuf));
- RegSetValueExA( RegKey, "DhcpNameServer", 0, REG_MULTI_SZ,
- (LPBYTE)nsbuf, len + 1 );
+ RegSetValueExA( RegKey, "DhcpNameServer", 0, REG_SZ,
+ (LPBYTE)nsbuf, strlen(nsbuf) + 1 );
free( nsbuf );
}
Modified: trunk/reactos/dll/win32/iphlpapi/resinfo_reactos.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/iphlpapi/resinfo…
==============================================================================
--- trunk/reactos/dll/win32/iphlpapi/resinfo_reactos.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/iphlpapi/resinfo_reactos.c [iso-8859-1] Mon Aug 23 21:11:01
2010
@@ -122,24 +122,47 @@
void EnumNameServers( HANDLE RegHandle, PWCHAR Interface,
PVOID Data, EnumNameServersFunc cb ) {
- PWCHAR *NameServerString =
- QueryRegistryValueStringMulti(RegHandle, L"DhcpNameServer");
- DWORD i;
+ PWCHAR NameServerString =
+ QueryRegistryValueString(RegHandle, L"DhcpNameServer");
if (!NameServerString)
- NameServerString = QueryRegistryValueStringMulti(RegHandle, L"NameServer");
-
- if (!NameServerString) return;
-
- for (i = 0; NameServerString[i]; i++)
- {
- cb(Interface, NameServerString[i], Data);
-
- HeapFree(GetProcessHeap(), 0, NameServerString[i]);
- }
-
- HeapFree(GetProcessHeap(), 0, NameServerString);
-}
+ NameServerString = QueryRegistryValueString(RegHandle, L"NameServer");
+
+ if (NameServerString) {
+ /* Now, count the non-empty comma separated */
+ DWORD ch;
+ DWORD LastNameStart = 0;
+ for (ch = 0; NameServerString[ch]; ch++) {
+ if (NameServerString[ch] == ',') {
+ if (ch - LastNameStart > 0) { /* Skip empty entries */
+ PWCHAR NameServer =
+ malloc(((ch - LastNameStart) + 1) * sizeof(WCHAR));
+ if (NameServer) {
+ memcpy(NameServer,NameServerString + LastNameStart,
+ (ch - LastNameStart) * sizeof(WCHAR));
+ NameServer[ch - LastNameStart] = 0;
+ cb( Interface, NameServer, Data );
+ free(NameServer);
+ LastNameStart = ch +1;
+ }
+ }
+ LastNameStart = ch + 1; /* The first one after the comma */
+ }
+ }
+ if (ch - LastNameStart > 0) { /* A last name? */
+ PWCHAR NameServer = malloc(((ch - LastNameStart) + 1) * sizeof(WCHAR));
+ if (NameServer) {
+ memcpy(NameServer,NameServerString + LastNameStart,
+ (ch - LastNameStart) * sizeof(WCHAR));
+ NameServer[ch - LastNameStart] = 0;
+ cb( Interface, NameServer, Data );
+ free(NameServer);
+ }
+ }
+ ConsumeRegValueString(NameServerString);
+ }
+}
+
static void CreateNameServerListEnumNamesFuncCount( PWCHAR Interface,
PWCHAR Server,
PVOID _Data ) {