1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 14:11:29 +00:00

Match against both destination and gateway in sysroutes_dnet_find_interfaces.

This commit fixes two different bugs:

(1) First in some situations Nmap will only see routes that are attached
to the device that handles the default route.

(2) On boxes without a default route, Nmap will not see any route.

These two bugs are caused by sysroutes_dnet_find_interfaces() logic
which will use only the geteway to match interface addresses.

To fix this, first check the current route and see if the gateway was set
otherwise use the destination address to match the address of an
interface.
This commit is contained in:
david
2012-09-30 00:01:14 +00:00
parent 6c8b5c7dd9
commit 22d49bd5c9

View File

@@ -1539,12 +1539,21 @@ static struct dnet_collector_route_nfo *sysroutes_dnet_find_interfaces(struct dn
if (dcrn->routes[i].device != NULL)
continue;
/* First we match up routes whose gateway address directly matches the
address of an interface. */
/* First we match up routes whose gateway or destination address
directly matches the address of an interface. */
struct sys_route *route = &dcrn->routes[i];
struct sockaddr_storage *routeaddr;
/* First see if the gateway was set */
if (sockaddr_equal_zero(&route->gw))
routeaddr = &dcrn->routes[i].dest;
else
routeaddr = &dcrn->routes[i].gw;
for (j = 0; j < numifaces; j++) {
if (!ifaces[j].device_up)
continue;
if (sockaddr_equal_netmask(&ifaces[j].addr, &dcrn->routes[i].gw, ifaces[j].netmask_bits)) {
if (sockaddr_equal_netmask(&ifaces[j].addr, routeaddr, ifaces[j].netmask_bits)) {
dcrn->routes[i].device = &ifaces[j];
break;
}