Index: osscan2.cc =================================================================== --- osscan2.cc (revision 4198) +++ osscan2.cc (working copy) @@ -526,6 +526,9 @@ OsScanInfo(vector &Targets); ~OsScanInfo(); + /* If you remove from this, you had better adjust nextI too (or call + resetHostIterator() afterward). Don't let this list get empty, + then add to it again, or you may mess up nextI (I'm not sure) */ list incompleteHosts; unsigned int starttimems; @@ -536,6 +539,11 @@ first host in the list. If incompleteHosts is empty, returns NULL. */ HostOsScanInfo *nextIncompleteHost(); + /* Resets the host iterator used with nextIncompleteHost() to the + beginning. If you remove a host from incompleteHosts, call this + right afterward */ + void resetHostIterator() { nextI = incompleteHosts.begin(); } + int removeCompletedHosts(); private: unsigned int numInitialTargets; @@ -3653,18 +3661,18 @@ hsi->isCompleted = true; } - if (islocalhost(hsi->target->v4hostip())) { - /* scanning localhost */ - distance = 0; - } else if (hsi->target->MACAddress()) { - /* on the same network segment */ - distance = 1; - } else if (hsi->hss->distance!=-1) { - distance = hsi->hss->distance; - } - - hsi->target->distance = hsi->target->FPR->distance = distance; - hsi->target->FPR->distance_guess = hsi->hss->distance_guess; + if (islocalhost(hsi->target->v4hostip())) { + /* scanning localhost */ + distance = 0; + } else if (hsi->target->MACAddress()) { + /* on the same network segment */ + distance = 1; + } else if (hsi->hss->distance!=-1) { + distance = hsi->hss->distance; + } + + hsi->target->distance = hsi->target->FPR->distance = distance; + hsi->target->FPR->distance_guess = hsi->hss->distance_guess; } @@ -3774,6 +3782,8 @@ to unMatchedHosts */ HOS->target->stopTimeOutClock(&now); OSI->incompleteHosts.erase(hostI); + /* We need to adjust nextI if necessary */ + OSI->resetHostIterator(); hostsRemoved++; unMatchedHosts->push_back(HOS); } @@ -3826,6 +3836,7 @@ (*(OSI->incompleteHosts.begin()))->target->NameIP(targetstr, sizeof(targetstr)); } else snprintf(targetstr, sizeof(targetstr), "%d hosts", (int) OSI->numIncompleteHosts()); printf("%s OS detection (try #%d) against %s\n", (itry == 0)? "Initiating" : "Retrying", itry + 1, targetstr); + log_flush_all(); } startRound(OSI, HOS, itry); doSeqTests(OSI, HOS);