1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-17 05:09:00 +00:00

Fixing a "bug" in Traceroute output. The ScanProgressMeter's endTask() was never called, which threw the output (stdout/XML etc) out of whack. This localizes the SPM stuff to Traceroute::trace(), and all is well :)

This commit is contained in:
kris
2007-03-18 00:37:33 +00:00
parent e9d1e9f640
commit 888af63431
3 changed files with 9 additions and 4 deletions

View File

@@ -1,4 +1,8 @@
# Nmap Changelog ($Id$); -*-text-*- # Nmap Changelog ($Id$); -*-text-*-
o Fix a small bug in traceroute progress output which neglected printing
when it was completed. This caused weirdness, especially when multiple
hosts were scanned. [Kris]
o Fix a portability problem related to the new traceroute o Fix a portability problem related to the new traceroute
functionality so that it compiles on Mac OS X. Thanks to Christophe functionality so that it compiles on Mac OS X. Thanks to Christophe
Thil for reporting the problem and sending the 1-line fix. Thil for reporting the problem and sending the 1-line fix.

View File

@@ -218,7 +218,6 @@ Traceroute::Traceroute (const char *device_name, devtype type) {
/* rely on each group using the same device */ /* rely on each group using the same device */
pd = my_pcap_open_live (device_name, 100, o.spoofsource ? 1 : 0, 2); pd = my_pcap_open_live (device_name, 100, o.spoofsource ? 1 : 0, 2);
SPM = new ScanProgressMeter ("Traceroute");
scaninfo.initial_proto = IPPROTO_IP; scaninfo.initial_proto = IPPROTO_IP;
scaninfo.open_response = 0; scaninfo.open_response = 0;
@@ -304,8 +303,6 @@ Traceroute::~Traceroute () {
free(hops); free(hops);
for (; it != TraceGroups.end (); ++it) for (; it != TraceGroups.end (); ++it)
delete (it->second); delete (it->second);
assert(SPM != NULL);
delete (SPM);
if (ethsd) if (ethsd)
ethsd = NULL; ethsd = NULL;
close (fd); close (fd);
@@ -789,6 +786,7 @@ Traceroute::trace (vector < Target * >&Targets) {
TraceProbe *tp = NULL; TraceProbe *tp = NULL;
TraceGroup *tg = NULL; TraceGroup *tg = NULL;
Target *t = NULL; Target *t = NULL;
ScanProgressMeter *SPM;
u16 total_size, total_complete; u16 total_size, total_complete;
if (o.af () == AF_INET6) { if (o.af () == AF_INET6) {
@@ -816,6 +814,8 @@ Traceroute::trace (vector < Target * >&Targets) {
* legitimate to trace to */ * legitimate to trace to */
sendTTLProbes (Targets, valid_targets); sendTTLProbes (Targets, valid_targets);
SPM = new ScanProgressMeter ("Traceroute");
while (!readTraceResponses ()) { while (!readTraceResponses ()) {
for (targ = valid_targets.begin (); targ != valid_targets.end (); ++targ) { for (targ = valid_targets.begin (); targ != valid_targets.end (); ++targ) {
t = *targ; t = *targ;
@@ -861,6 +861,8 @@ Traceroute::trace (vector < Target * >&Targets) {
swap (total_complete, total_size); swap (total_complete, total_size);
SPM->printStats (MIN ((double) total_complete / total_size, 0.99), NULL); SPM->printStats (MIN ((double) total_complete / total_size, 0.99), NULL);
} }
SPM->endTask(NULL, NULL);
delete (SPM);
} }
/* Resolves traceroute hops through nmaps /* Resolves traceroute hops through nmaps

View File

@@ -317,7 +317,6 @@ class Traceroute {
struct scan_info scaninfo; struct scan_info scaninfo;
ScanProgressMeter *SPM;
Target **hops; Target **hops;
pcap_t *pd; pcap_t *pd;
eth_t *ethsd; eth_t *ethsd;