From 4643b5585f171b048e1555d474f80d6ef2d97199 Mon Sep 17 00:00:00 2001 From: Erik Auerswald Date: Sat, 30 Nov 2024 18:48:44 +0100 Subject: [PATCH] initialize ICMP timestamp fields Initializing the timestamp variables avoids accesssing uninitialized memory when using --icmp-timestamp with an IPv6 target. Per RFC 792, setting the high bit indicates a non-standard value, i.e., this is not a valid timestamp. Thus this value can be distinguished from valid timestamps. --- src/fping.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fping.c b/src/fping.c index 9209ac3..029341f 100644 --- a/src/fping.c +++ b/src/fping.c @@ -2413,9 +2413,9 @@ int wait_for_reply(int64_t wait_time) int ip_header_tos = -1; int ip_header_ttl = -1; // ICMP Timestamp - uint32_t ip_header_otime_ms; - uint32_t ip_header_rtime_ms; - uint32_t ip_header_ttime_ms; + uint32_t ip_header_otime_ms = 0x80000000U; + uint32_t ip_header_rtime_ms = 0x80000000U; + uint32_t ip_header_ttime_ms = 0x80000000U; /* Receive packet */ result = receive_packet(wait_time, /* max. wait time, in ns */ -- 2.43.0