getipaddrlist-20040318

Improve error checking in GetNumOfIpAddrs to prevent potential
invalid memory access if the IP Address Table cannot be accessed.
(win2000 with no privs)
This commit is contained in:
Jeffrey Altman 2004-03-19 05:16:24 +00:00 committed by Jeffrey Altman
parent 48913f747f
commit e1cc03f597

View File

@ -3449,9 +3449,11 @@ GetNumOfIpAddrs(void)
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);
}