diff options
author | Guy Harris <guy@alum.mit.edu> | 2017-09-20 19:17:22 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2017-09-20 19:17:22 -0700 |
commit | 0aa9e5a41723aa01959893ee065647d26665584f (patch) | |
tree | 1578fd810f3cd1ae0e5c641bda7be1c8c2b418fb /print-hncp.c | |
parent | 40bcb22217cfcc03b9e9d963955c2d460b890e82 (diff) | |
download | tcpdump-0aa9e5a41723aa01959893ee065647d26665584f.tar.gz |
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.
Diffstat (limited to 'print-hncp.c')
0 files changed, 0 insertions, 0 deletions