Fix assertion failure in do_one_select_round

Since the refactor in r33185, getting a good response for a host during
a ping scan can remove all outstanding probes for that host, since we
already know the host is up. This broke the existing iteration in some
cases. I could force the crash with: nmap -sn -PS80-89 scanme.nmap.org

Now we check explicitly for an empty list each time through the loop.
This commit is contained in:
dmiller 2014-07-08 15:17:12 +00:00
parent 65c50eb695
commit 567e344ad7

View file

@ -4203,7 +4203,7 @@ static bool do_one_select_round(UltraScanInfo *USI, struct timeval *stime) {
std::list<UltraProbe *>::iterator nextProbeI;
for (std::list<UltraProbe *>::iterator probeI = host->probes_outstanding.begin(), end = host->probes_outstanding.end();
probeI != end && numGoodSD < selectres; probeI = nextProbeI) {
probeI != end && numGoodSD < selectres && host->num_probes_outstanding() > 0; probeI = nextProbeI) {
/* handleConnectResult may remove the probe at probeI, which invalidates
* the iterator. We copy and increment it here instead of in the for-loop
* statement to avoid incrementing an invalid iterator */