From 3dc65c8b2cba4c08c1ae1f8784cb6269547898ce Mon Sep 17 00:00:00 2001 From: kris Date: Sat, 14 Jun 2008 07:06:12 +0000 Subject: [PATCH] o Fixed several byte-order bugs in Traceroute. [Kris] --- CHANGELOG | 2 ++ traceroute.cc | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c601f43b5..9498f62c1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -45,6 +45,8 @@ o Fixed an integer overflow which prevented a target specification o Fixed some memory leaks in NSE found with Valgrind. [Kris] +o Fixed several byte-order bugs in Traceroute. [Kris] + o Nmap now returns correct values for --iflist in windows even if interface aliases have been set. Previously it would misreport the windevices and not list all interfaces. [Michael] diff --git a/traceroute.cc b/traceroute.cc index 89cb76b1f..9760dbec9 100644 --- a/traceroute.cc +++ b/traceroute.cc @@ -437,19 +437,19 @@ Traceroute::readTraceResponses () { tcp = (struct tcp_hdr *) ((u8 *) ip2 + ip2->ip_hl * 4); if (ntohs(ip2->ip_len) - (ip2->ip_hl * 4) < 2) break; - sport = htons (tcp->th_sport); + sport = ntohs (tcp->th_sport); } else if (ip2->ip_p == IPPROTO_UDP) { udp = (struct udp_hdr *) ((u8 *) ip2 + ip2->ip_hl * 4); if (ntohs(ip2->ip_len) - (ip2->ip_hl * 4) < 2) break; - sport = htons (udp->uh_sport); + sport = ntohs (udp->uh_sport); } else if (ip2->ip_p == IPPROTO_ICMP) { icmp2 = (struct icmp *) ((char *) ip2 + 4 * ip2->ip_hl); if (ntohs(ip2->ip_len) - (ip2->ip_hl * 4) < 8) break; sport = ntohs(icmp2->icmp_id); } else { - sport = htons(ip2->ip_id); + sport = ntohs(ip2->ip_id); } ipaddr = ip2->ip_dst.s_addr; } @@ -540,8 +540,8 @@ Traceroute::readTraceResponses () { else break; - if (tg->TraceProbes.find (htons (tcp->th_dport)) != tg->TraceProbes.end ()) - tp = tg->TraceProbes[htons (tcp->th_dport)]; + if (tg->TraceProbes.find (ntohs (tcp->th_dport)) != tg->TraceProbes.end ()) + tp = tg->TraceProbes[ntohs (tcp->th_dport)]; else break; @@ -584,8 +584,8 @@ Traceroute::readTraceResponses () { else break; - if (tg->TraceProbes.find (htons (udp->uh_dport)) != tg->TraceProbes.end ()) - tp = tg->TraceProbes[htons (udp->uh_dport)]; + if (tg->TraceProbes.find (ntohs (udp->uh_dport)) != tg->TraceProbes.end ()) + tp = tg->TraceProbes[ntohs (udp->uh_dport)]; else break;