]> git.gsnw.org Git - fping.git/commitdiff
initialize ICMP timestamp fields
authorErik Auerswald <auerswal@unix-ag.uni-kl.de>
Sat, 30 Nov 2024 17:48:44 +0000 (18:48 +0100)
committerErik Auerswald <auerswal@unix-ag.uni-kl.de>
Sat, 7 Dec 2024 19:04:17 +0000 (20:04 +0100)
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

index 9209ac30baee90c7d8bfb84f3aa34f51f02eb955..029341fd444574d053517b6e3b5e7742c34ac702 100644 (file)
@@ -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 */