getipaddrlist-20040318
authorJeffrey Altman <jaltman@mit.edu>
Fri, 19 Mar 2004 05:16:24 +0000 (05:16 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 19 Mar 2004 05:16:24 +0000 (05:16 +0000)
Improve error checking in GetNumOfIpAddrs to prevent potential
invalid memory access if the IP Address Table cannot be accessed.
(win2000 with no privs)

src/WINNT/client_creds/afskfw.c

index 1a00fe8..bedb85f 100644 (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);
     }