Commit cd1ed081 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

iphlpapi: Use a separate index to count addresses in GetAdaptersAddresses.

Fixes address enumeration when an interfaces is not configured with an IP address or when an interface is configured with more than one address.
parent c23ccc03
...@@ -611,7 +611,7 @@ static DWORD typeFromMibType(DWORD mib_type) ...@@ -611,7 +611,7 @@ static DWORD typeFromMibType(DWORD mib_type)
static ULONG addressesFromIndex(DWORD index, DWORD **addrs, ULONG *num_addrs) static ULONG addressesFromIndex(DWORD index, DWORD **addrs, ULONG *num_addrs)
{ {
ULONG ret, i; ULONG ret, i, j;
MIB_IPADDRTABLE *at; MIB_IPADDRTABLE *at;
*num_addrs = 0; *num_addrs = 0;
...@@ -625,9 +625,9 @@ static ULONG addressesFromIndex(DWORD index, DWORD **addrs, ULONG *num_addrs) ...@@ -625,9 +625,9 @@ static ULONG addressesFromIndex(DWORD index, DWORD **addrs, ULONG *num_addrs)
HeapFree(GetProcessHeap(), 0, at); HeapFree(GetProcessHeap(), 0, at);
return ERROR_OUTOFMEMORY; return ERROR_OUTOFMEMORY;
} }
for (i = 0; i < at->dwNumEntries; i++) for (i = 0, j = 0; i < at->dwNumEntries; i++)
{ {
if (at->table[i].dwIndex == index) (*addrs)[i] = at->table[i].dwAddr; if (at->table[i].dwIndex == index) (*addrs)[j++] = at->table[i].dwAddr;
} }
HeapFree(GetProcessHeap(), 0, at); HeapFree(GetProcessHeap(), 0, at);
return ERROR_SUCCESS; return ERROR_SUCCESS;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment