inetmib1: Check for failure of the iphlpapi functions instead of blindly trusting them.
This commit is contained in:
parent
70a9d70ba5
commit
5530977fdb
|
@ -107,9 +107,12 @@ static void mib2IfNumberInit(void)
|
||||||
|
|
||||||
if (ret == ERROR_INSUFFICIENT_BUFFER)
|
if (ret == ERROR_INSUFFICIENT_BUFFER)
|
||||||
{
|
{
|
||||||
ifTable = HeapAlloc(GetProcessHeap(), 0, size);
|
MIB_IFTABLE *table = HeapAlloc(GetProcessHeap(), 0, size);
|
||||||
if (ifTable)
|
if (table)
|
||||||
GetIfTable(ifTable, &size, FALSE);
|
{
|
||||||
|
if (!GetIfTable(table, &size, FALSE)) ifTable = table;
|
||||||
|
else HeapFree(GetProcessHeap(), 0, table );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -633,9 +636,12 @@ static void mib2IpAddrInit(void)
|
||||||
|
|
||||||
if (ret == ERROR_INSUFFICIENT_BUFFER)
|
if (ret == ERROR_INSUFFICIENT_BUFFER)
|
||||||
{
|
{
|
||||||
ipAddrTable = HeapAlloc(GetProcessHeap(), 0, size);
|
MIB_IPADDRTABLE *table = HeapAlloc(GetProcessHeap(), 0, size);
|
||||||
if (ipAddrTable)
|
if (table)
|
||||||
GetIpAddrTable(ipAddrTable, &size, TRUE);
|
{
|
||||||
|
if (!GetIpAddrTable(table, &size, TRUE)) ipAddrTable = table;
|
||||||
|
else HeapFree(GetProcessHeap(), 0, table );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -721,9 +727,12 @@ static void mib2IpRouteInit(void)
|
||||||
|
|
||||||
if (ret == ERROR_INSUFFICIENT_BUFFER)
|
if (ret == ERROR_INSUFFICIENT_BUFFER)
|
||||||
{
|
{
|
||||||
ipRouteTable = HeapAlloc(GetProcessHeap(), 0, size);
|
MIB_IPFORWARDTABLE *table = HeapAlloc(GetProcessHeap(), 0, size);
|
||||||
if (ipRouteTable)
|
if (table)
|
||||||
GetIpForwardTable(ipRouteTable, &size, TRUE);
|
{
|
||||||
|
if (!GetIpForwardTable(ipRouteTable, &size, TRUE)) ipRouteTable = table;
|
||||||
|
else HeapFree(GetProcessHeap(), 0, table );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -801,9 +810,12 @@ static void mib2IpNetInit(void)
|
||||||
|
|
||||||
if (ret == ERROR_INSUFFICIENT_BUFFER)
|
if (ret == ERROR_INSUFFICIENT_BUFFER)
|
||||||
{
|
{
|
||||||
ipNetTable = HeapAlloc(GetProcessHeap(), 0, size);
|
MIB_IPNETTABLE *table = HeapAlloc(GetProcessHeap(), 0, size);
|
||||||
if (ipNetTable)
|
if (table)
|
||||||
GetIpNetTable(ipNetTable, &size, FALSE);
|
{
|
||||||
|
if (!GetIpNetTable(ipNetTable, &size, FALSE)) ipNetTable = table;
|
||||||
|
else HeapFree(GetProcessHeap(), 0, table );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1047,9 +1059,12 @@ static void mib2UdpEntryInit(void)
|
||||||
|
|
||||||
if (ret == ERROR_INSUFFICIENT_BUFFER)
|
if (ret == ERROR_INSUFFICIENT_BUFFER)
|
||||||
{
|
{
|
||||||
udpTable = HeapAlloc(GetProcessHeap(), 0, size);
|
MIB_UDPTABLE *table = HeapAlloc(GetProcessHeap(), 0, size);
|
||||||
if (udpTable)
|
if (table)
|
||||||
GetUdpTable(udpTable, &size, TRUE);
|
{
|
||||||
|
if (!GetUdpTable(table, &size, TRUE)) udpTable = table;
|
||||||
|
else HeapFree(GetProcessHeap(), 0, table);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue