mirror of
https://github.com/nmap/nmap.git
synced 2026-10-20 19:01:56 +00:00
Enforce device name only after choosing loopback in route_dst_generic.
Nping calls route_dst at least twice: once with a NULL device, and again with the device learned from the first time. This interfered with the code that automatically chooses a loopback interface for dests that are the same as an interface address. For example, if you are 192.168.0.1, and you are scanning 192.168.0.1, route_dst will tell you to use interface "lo0" even though the interface of 192.168.0.1 may be "eth0". route_dst was returning failure because the device name check was being done before "eth0" got changed to "lo0". This problem didn't show up on Linux because Linux uses route_dst_netlink, which delegates the work to the kernel. But I could reproduce on Linux by forcing the use of route_dst_generic.
This commit is contained in:
parent
9e74850e6e
commit
66bd9d1993
1 changed files with 3 additions and 2 deletions
|
|
@ -3344,8 +3344,6 @@ static int route_dst_generic(const struct sockaddr_storage *dst,
|
|||
|
||||
if (!sockaddr_equal(dst, &ifaces[i].addr))
|
||||
continue;
|
||||
if (iface != NULL && strcmp(ifaces[i].devname, iface->devname) != 0)
|
||||
continue;
|
||||
|
||||
if (ifaces[i].device_type == devt_loopback)
|
||||
loopback = &ifaces[i];
|
||||
|
|
@ -3355,6 +3353,9 @@ static int route_dst_generic(const struct sockaddr_storage *dst,
|
|||
/* Hmmm ... no localhost -- move on to the routing table. */
|
||||
break;
|
||||
|
||||
if (iface != NULL && strcmp(loopback->devname, iface->devname) != 0)
|
||||
continue;
|
||||
|
||||
rnfo->ii = *loopback;
|
||||
rnfo->direct_connect = 1;
|
||||
/* But the source address we want to use is the target address. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue