The following commit has been merged in the master branch: commit 57b5fbfd1be1ca15d8fa2fa43a3a223d2b639704 Author: Sven Eckelmann sven.eckelmann@gmx.de Date: Thu Nov 4 14:03:40 2010 +0100
batctl: Don't print uninitialised traceroute times
The time_delta array is only initialised when no error occurs or only the select fails. This means that we may print uninitialised or output from previous ttl levels.
Signed-off-by: Sven Eckelmann sven.eckelmann@gmx.de
diff --git a/traceroute.c b/traceroute.c index 0dc796a..f80ca4d 100644 --- a/traceroute.c +++ b/traceroute.c @@ -135,6 +135,7 @@ int traceroute(char *mesh_iface, int argc, char **argv)
for (i = 0; i < NUM_PACKETS; i++) { icmp_packet_out.seqno = htons(++seq_counter); + time_delta[i] = 0.0;
if (write(trace_fd, (char *)&icmp_packet_out, sizeof(icmp_packet_out)) < 0) { printf("Error - can't write to batman adv kernel file '%s': %s\n", icmp_socket, strerror(errno)); @@ -151,10 +152,8 @@ int traceroute(char *mesh_iface, int argc, char **argv)
res = select(trace_fd + 1, &read_socket, NULL, NULL, &tv);
- if (res <= 0) { - time_delta[i] = 0.0; + if (res <= 0) continue; - }
read_len = read(trace_fd, (char *)&icmp_packet_in, sizeof(icmp_packet_in));