/*
* Definitions for the masses
*/
-#define JAN_1970 2208988800U /* 1970 - 1900 in seconds */
+#define JAN_1970 2208988800 /* 1970 - 1900 in seconds */
/*
* Structure definitions for NTP fixed point values
p_ntp_time(netdissect_options *ndo,
register const struct l_fixedpt *lfp)
{
- register int32_t i;
+ register uint32_t i;
register uint32_t uf;
register uint32_t f;
register double ff;
* print the UTC time in human-readable format.
*/
if (i) {
- time_t seconds = i - JAN_1970;
+ int64_t seconds_64bit = (int64_t)i - JAN_1970;
+ time_t seconds;
struct tm *tm;
char time_buf[128];
- tm = gmtime(&seconds);
- /* use ISO 8601 (RFC3339) format */
- strftime(time_buf, sizeof (time_buf), "%Y-%m-%dT%H:%M:%S", tm);
- ND_PRINT((ndo, " (%s)", time_buf));
+ seconds = (time_t)seconds_64bit;
+ if (seconds != seconds_64bit) {
+ /*
+ * It doesn't fit into a time_t, so we can't hand it
+ * to gmtime.
+ */
+ ND_PRINT((ndo, " (unrepresentable)"));
+ } else {
+ tm = gmtime(&seconds);
+ if (tm == NULL) {
+ /*
+ * gmtime() can't handle it.
+ * (Yes, that might happen with some version of
+ * Microsoft's C library.)
+ */
+ ND_PRINT((ndo, " (unrepresentable)"));
+ } else {
+ /* use ISO 8601 (RFC3339) format */
+ strftime(time_buf, sizeof (time_buf), "%Y-%m-%dT%H:%M:%S", tm);
+ ND_PRINT((ndo, " (%s)", time_buf));
+ }
+ }
}
#endif
}
+++ /dev/null
-#!/bin/sh
-
-exitcode=0
-passed=`cat .passed`
-failed=`cat .failed`
-
-# Only attempt tests with times outside the range of 32-bit time_t
-# when running on a 64-bit processor.
-
-if file ../tcpdump | egrep '64|PA-RISC2.0' >/dev/null
-then
- #
- # The file type of tcpdump contains the number 64 or the string
- # "PA-RISC2.0"; we'll assume that means it's a 64-bit executable.
- #
- if ./TESTonce ntp ntp.pcap ntp.out ""
- then
- passed=`expr $passed + 1`
- echo $passed >.passed
- else
- failed=`expr $failed + 1`
- echo $failed >.failed
- exitcode=1
- fi
- #
- # The file type of tcpdump contains the number 64 or the string
- # "PA-RISC2.0"; we'll assume that means it's a 64-bit executable.
- #
- if ./TESTonce ntp ntp.pcap ntp-v.out -v
- then
- passed=`expr $passed + 1`
- echo $passed >.passed
- else
- failed=`expr $failed + 1`
- echo $failed >.failed
- exitcode=1
- fi
-else
- FORMAT=' %-35s: TEST SKIPPED (running 32-bit)\n'
- printf "$FORMAT" ntp
-
-fi
-
-exit $exitcode
Root Delay: 0.000000, Root dispersion: 0.000000, Reference-ID: (unspec)
Reference Timestamp: 0.000000000
Originator Timestamp: 3706870757.473833108 (2017-06-19T14:19:17)
- Receive Timestamp: 1802554105.693999877 (2093-03-22T03:56:41)
+ Receive Timestamp: 1802554105.693999877 (1957-02-13T21:28:25)
Transmit Timestamp: 2929527464.107565978 (1992-10-31T13:37:44)
Originator - Receive Timestamp: -1904316651.779833231
Originator - Transmit Timestamp: -777343293.366267130