mirror of
https://github.com/the-tcpdump-group/tcpdump.git
synced 2024-11-23 01:53:55 +08:00
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).
This commit is contained in:
parent
a41457a51a
commit
ad5e31b10c
@ -63,6 +63,20 @@ $testlist = [
|
||||
output => 'time_2107.out',
|
||||
args => '-q'
|
||||
},
|
||||
{
|
||||
config_set => 'HAVE_TIME_T_64',
|
||||
name => 'time_2106_overflow-tt',
|
||||
input => 'time_2106_overflow.pcapng',
|
||||
output => 'time_2106_overflow-tt.out',
|
||||
args => '-tt -q SPECIAL_t'
|
||||
},
|
||||
{
|
||||
config_set => 'HAVE_TIME_T_64',
|
||||
name => 'time_2107-tt',
|
||||
input => 'time_2107.pcapng',
|
||||
output => 'time_2107-tt.out',
|
||||
args => '-tt -q SPECIAL_t'
|
||||
},
|
||||
];
|
||||
|
||||
1;
|
||||
|
1
tests/time_2106_overflow-tt.out
Normal file
1
tests/time_2106_overflow-tt.out
Normal file
@ -0,0 +1 @@
|
||||
1 4294967296.000000 IP 192.168.1.11.43966 > 209.87.249.18.53: UDP, length 56
|
1
tests/time_2107-tt.out
Normal file
1
tests/time_2107-tt.out
Normal file
@ -0,0 +1 @@
|
||||
1 4323283200.000000 IP 192.168.1.11.43966 > 209.87.249.18.53: UDP, length 56
|
@ -293,7 +293,7 @@ ts_unix_print(netdissect_options *ndo, const struct timeval *tv)
|
||||
return;
|
||||
}
|
||||
|
||||
ND_PRINT("%u", (unsigned)tv->tv_sec);
|
||||
ND_PRINT("%" PRId64, (int64_t)tv->tv_sec);
|
||||
ts_frac_print(ndo, tv);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user