From 7ac1b98cb4f884adde4c999634f4db634a8eaa6d Mon Sep 17 00:00:00 2001 From: kris Date: Sun, 28 Oct 2007 00:30:19 +0000 Subject: [PATCH] Of course, after I commit the big patch I find a possible bug :) In case we can't findHost() on a packet received doing the IPProto Ping --- scan_engine.cc | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/scan_engine.cc b/scan_engine.cc index 7a22202c7..a8dd83ade 100644 --- a/scan_engine.cc +++ b/scan_engine.cc @@ -3830,7 +3830,7 @@ static int get_ping_pcap_result(UltraScanInfo *USI, struct timeval *stime) { HostScanStats *hss = NULL; struct sockaddr_in sin; list::iterator probeI; - UltraProbe *probe; + UltraProbe *probe = NULL; unsigned int trynum = 0; unsigned int pingseq = 0; bool goodseq; @@ -3876,25 +3876,24 @@ static int get_ping_pcap_result(UltraScanInfo *USI, struct timeval *stime) { sin.sin_addr.s_addr = ip->ip_src.s_addr; sin.sin_family = AF_INET; hss = USI->findHost((struct sockaddr_storage *) &sin); - if (hss) { - setTargetMACIfAvailable(hss->target, &linkhdr, ip, 0); - probeI = hss->probes_outstanding.end(); - listsz = hss->num_probes_outstanding(); - goodone = false; - for(probenum = 0; probenum < listsz && !goodone; probenum++) { - probeI--; - probe = *probeI; + if (!hss) continue; + setTargetMACIfAvailable(hss->target, &linkhdr, ip, 0); + probeI = hss->probes_outstanding.end(); + listsz = hss->num_probes_outstanding(); + goodone = false; + for(probenum = 0; probenum < listsz && !goodone; probenum++) { + probeI--; + probe = *probeI; - if (probe->protocol() == ip->ip_p) { - /* if this is our probe we sent to localhost, then it doesn't count! */ - if (ip->ip_src.s_addr == ip->ip_dst.s_addr && - probe->ipid() == ntohs(ip->ip_id)) - continue; + if (probe->protocol() == ip->ip_p) { + /* if this is our probe we sent to localhost, then it doesn't count! */ + if (ip->ip_src.s_addr == ip->ip_dst.s_addr && + probe->ipid() == ntohs(ip->ip_id)) + continue; - newstate = HOST_UP; - current_reason = ER_PROTORESPONSE; - goodone = true; - } + newstate = HOST_UP; + current_reason = ER_PROTORESPONSE; + goodone = true; } } }