]> 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)
committerfxlb <[email protected]>
Sat, 28 Sep 2024 14:01:32 +0000 (14:01 +0000)
commitad5e31b10c83431845292be5ca4bfa0f284840fd
tree3f1c4212fe9178ed6c0f7412b0fefc61df015ca1
parenta41457a51afbdce841aca97518f871a247939ff3
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).
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