Nmap Development mailing list archives

[PATCH] Exit from getsysroutes() earlier if 'howmany == NULL'


From: Kris Katterjohn <kjak () ispwest com>
Date: Thu, 14 Sep 2006 21:57:03 -0500

The attached patch checks for a NULL 'howmany' pointer in getsysroutes()
before going through the rest of the function. If 'howmany' is NULL,
fatal() is called so there's no reason to go through the rest if we just
exit.

It's a diff against 4.20ALPHA7.

Thanks,
Kris Katterjohn
--- x/tcpip.cc  2006-08-28 22:26:10.000000000 -0500
+++ y/tcpip.cc  2006-09-14 21:51:46.000000000 -0500
@@ -2771,6 +2771,8 @@ struct sys_route *getsysroutes(int *howm
   struct sockaddr_in *sin;
   struct interface_info *ii;
 
+  if (!howmany) fatal("NULL howmany ptr passed to getsysroutes()");
+
   if (!routes) {
     routes = (struct sys_route *) safe_zalloc(route_capacity * sizeof(struct sys_route));
     ifaces = getinterfaces(&numifaces);
@@ -2888,7 +2890,6 @@ struct sys_route *getsysroutes(int *howm
       qsort(routes, numroutes, sizeof(routes[0]), nmaskcmp);
     }
   }
-  if (!howmany) fatal("NULL howmany ptr passed to getsysroutes()");
   *howmany = numroutes;
   return routes;
 }

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org

Current thread: