]> The Tcpdump Group git mirrors - tcpdump/commit
Fix handling of NTP time stamps.
authorGuy Harris <[email protected]>
Thu, 21 Sep 2017 02:17:22 +0000 (19:17 -0700)
committerGuy Harris <[email protected]>
Thu, 21 Sep 2017 02:17:22 +0000 (19:17 -0700)
commit0aa9e5a41723aa01959893ee065647d26665584f
tree1578fd810f3cd1ae0e5c641bda7be1c8c2b418fb
parent40bcb22217cfcc03b9e9d963955c2d460b890e82
Fix handling of NTP time stamps.

The seconds value in a 64-bit NTP timestamp is unsigned.  Treat it as
such.

When converting it to a UN*X seconds-since-the-Epoch, cast the 32-bit
seconds value from an NTP timestap to a 64-bit signed value (which is
always possible), and then subtract the signed delta between 1900 and
1970, giving a signed seconds-since-the-Epoch value.

Then assign that to a time_t; if that variable doesn't have the same
value as the calculated 64-bit value, we can't represent it in a time_t,
so just report it as unrepresentable.

Otherwise, use that resulting value in a gmtime() call - and make sure
gmtime() doesn't return NULL, which it can do with some versions of the
Microsoft C runtime.  If it does, report the time as unrepresentable,
otherwise report it as YYYY-MM-DDTHH:MM:SS.

This fixes the 32-bit vs. 64-bit issue for tests.

It also changes the test output, so update that.
print-ntp.c
tests/64bit.sh [deleted file]
tests/TESTLIST
tests/ntp-v.out