NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/45257: ping(8) prints bogus round-trip times after Year 2038



The following reply was made to PR bin/45257; it has been noted by GNATS.

From: Ryo Shimizu <ryo%nerv.org@localhost>
To: christos%zoulas.com@localhost (Christos Zoulas)
Cc: gnats-bugs%NetBSD.org@localhost, gnats-admin%netbsd.org@localhost, 
netbsd-bugs%netbsd.org@localhost,
        david%l8s.co.uk@localhost, tsutsui%ceres.dti.ne.jp@localhost
Subject: Re: bin/45257: ping(8) prints bogus round-trip times after Year 2038 
Date: Fri, 19 Aug 2011 02:17:59 +0900

 >Why all the complexity? All you should need is to cast to unsigned when
 >assigning.
 
 No. it is not enough.
 
 
 >@@ -995,7 +995,7 @@
 >                      struct tv32 tv32;
 > 
 >                      (void) memcpy(&tv32, icp->icmp_data, sizeof(tv32));
 >-                     tv.tv_sec = ntohl(tv32.tv32_sec);
 >+                     tv.tv_sec = (uint32_t)ntohl(tv32.tv32_sec);
 >                      tv.tv_usec = ntohl(tv32.tv32_usec);
 >                      triptime = diffsec(&last_rx, &tv);
 >                      tsum += triptime;
 
 
 In case of last_rx.tv_sec is over 0x100000000,
 diffsec(&last_rx, &tv) returns big value.
 
 e.g.) last_rx.tv_sec = 0x100000005, tv.tv_sec = 0x00000004, result is 
0x100000001.
 
 # date 210602070628.13 # unixtime 0xfffffffd
 Sun Feb  7 06:28:13 UTC 2106
 # ping localhost
 PING localhost (127.0.0.1): 56 data bytes
 64 bytes from 127.0.0.1: icmp_seq=0 ttl=255 time=0.019 ms
 64 bytes from 127.0.0.1: icmp_seq=1 ttl=255 time=0.026 ms
 64 bytes from 127.0.0.1: icmp_seq=2 ttl=255 time=4294967296000.025 ms
 64 bytes from 127.0.0.1: icmp_seq=3 ttl=255 time=4294967296000.024 ms
 64 bytes from 127.0.0.1: icmp_seq=4 ttl=255 time=4294967296000.027 ms
 64 bytes from 127.0.0.1: icmp_seq=5 ttl=255 time=4294967296000.026 ms
 ^C
 ----localhost PING Statistics----
 6 packets transmitted, 6 packets received, 0.0% packet loss
 round-trip min/avg/max/stddev = 
0.019/2863311530666.691/4294967296000.027/2217911574655.135 ms
 
 --
 ryo shimizu
 


Home | Main Index | Thread Index | Old Index