]> The Tcpdump Group git mirrors - tcpdump/commit
Fix '-tt' option printing when time > 2106-02-07T06:28:15Z
authorFrancois-Xavier Le Bail <[email protected]>
Fri, 27 Sep 2024 18:05:22 +0000 (20:05 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Mon, 30 Sep 2024 13:22:38 +0000 (15:22 +0200)
commit3c52a23c3b4829f3a0cd1a1120fbd25f2ef38cb0
tree0fdfaa48d0beddd0e2aef6a79759732f6293c84a
parent8c1fc7610be499e40807912df5f9a8f06446c36f
Fix '-tt' option printing when time > 2106-02-07T06:28:15Z

Currently the printing with '-tt' option (unix time) is incorrect.

Some examples:
1) test: time_2106_overflow-tt
0.000000 IP 192.168.1.11.43966 > 209.87.249.18.53: UDP, length 56
Should be:
4294967296.000000 IP 192.168.1.11.43966 > 209.87.249.18.53: UDP, length 56
2) test: time_2107-tt
28315904.000000 IP 192.168.1.11.43966 > 209.87.249.18.53: UDP, length 56
Should be:
4323283200.000000 IP 192.168.1.11.43966 > 209.87.249.18.53: UDP, length 56

Two build examples:
64-bit build: tv->tv_sec has type '__time_t' (aka 'long').
32-bit build with _TIME_BITS=64: tv->tv_sec has type '__time64_t'
  (aka 'long long').

Using 'unsigned' cast is incorrect for these 64-bit data.

Thus convert to 'int64_t' and print with '"%" PRId64'.

Add two test cases (existing pcapng printed with -tt).

(cherry picked from commit ad5e31b10c83431845292be5ca4bfa0f284840fd)
tests/time.tests
tests/time_2106_overflow-tt.out [new file with mode: 0644]
tests/time_2107-tt.out [new file with mode: 0644]
util-print.c