1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Actually use reply ttl for distance guessing in traceroute

This chunk of code in read_replies was generating valgrind errors
because reply.ttl was uninitialized:

  if (host->state == HostState::COUNTING_DOWN) {
    /* If this probe was past the target, skip ahead to what we think the
       actual distance is. */
    int distance = get_initial_ttl_guess(reply.ttl) - reply.ttl + 1;
    if (distance > 0 && distance < host->current_ttl)
      host->current_ttl = MIN(distance, MAX_TTL);
  }

My compiler was setting the initial value to 0, which meant that
distance was always 33, clearly wrong. Setting reply.ttl in decode_reply
silences the error and causes distance to be more accurate.
This commit is contained in:
dmiller
2014-09-15 17:27:10 +00:00
parent 53135e80b9
commit 9a155c269d

View File

@@ -1207,6 +1207,7 @@ static bool decode_reply(const void *ip, unsigned int len, Reply *reply) {
return false;
reply->from_addr = hdr.src;
reply->ttl = hdr.ttl;
if (hdr.version == 4 && hdr.proto == IPPROTO_ICMP) {
/* ICMP responses comprise all the TTL exceeded messages we expect from all