iphlpapi: Allocate space enough to handle all the possible ipv4 addresses.

This commit is contained in:
Marcus Meissner 2006-01-30 18:16:22 +01:00 committed by Alexandre Julliard
parent 7b6f85474e
commit b970b22037
1 changed files with 2 additions and 6 deletions

View File

@ -654,9 +654,7 @@ DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
* precisely enough space.
*/
size = sizeof(IP_ADAPTER_INFO) * numNonLoopbackInterfaces;
if (numIPAddresses > numNonLoopbackInterfaces)
size += (numIPAddresses - numNonLoopbackInterfaces) *
sizeof(IP_ADDR_STRING);
size += numIPAddresses * sizeof(IP_ADDR_STRING);
if (!pAdapterInfo || *pOutBufLen < size) {
*pOutBufLen = size;
ret = ERROR_BUFFER_OVERFLOW;
@ -670,9 +668,7 @@ DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
table = getNonLoopbackInterfaceIndexTable();
if (table) {
size = sizeof(IP_ADAPTER_INFO) * table->numIndexes;
if (ipAddrTable->dwNumEntries > numNonLoopbackInterfaces)
size += (ipAddrTable->dwNumEntries - numNonLoopbackInterfaces) *
sizeof(IP_ADDR_STRING);
size += ipAddrTable->dwNumEntries * sizeof(IP_ADDR_STRING);
if (*pOutBufLen < size) {
*pOutBufLen = size;
ret = ERROR_INSUFFICIENT_BUFFER;