Improve error checking in GetNumOfIpAddrs to prevent potential
invalid memory access if the IP Address Table cannot be accessed.
(win2000 with no privs)
if (code == ERROR_INSUFFICIENT_BUFFER) {
pIpAddrTable = malloc(dwSize);
code = GetIpAddrTable(pIpAddrTable, &dwSize, 0);
- for ( index=0; index < pIpAddrTable->dwNumEntries; index++ ) {
- if (pIpAddrTable->table[index].dwAddr != 0)
- validAddrs++;
+ if ( code == NO_ERROR ) {
+ for ( index=0; index < pIpAddrTable->dwNumEntries; index++ ) {
+ if (pIpAddrTable->table[index].dwAddr != 0)
+ validAddrs++;
+ }
}
free(pIpAddrTable);
}