tcpdump
tcpdump copied to clipboard
UndefinedBehaviorSanitizer: undefined-behavior print-zep.c:86
At line 86: https://github.com/the-tcpdump-group/tcpdump/blob/400643120a48eca33973f6a47b34f0dcfde4d20a/print-zep.c#L86
print-zep.c:86:22: runtime error: unsigned integer overflow: 16843009 - 2208988800 cannot be represented in type 'unsigned int'
cc: @kivinen
fxlb writes:
At line 86: https://github.com/the-tcpdump-group/tcpdump/blob/400643120a48eca33973f6a47b34f0dcfde4d20a/print-zep.c#L86
print-zep.c:86:22: runtime error: unsigned integer overflow: 16843009 - 2208988800 cannot be represented in type 'unsigned int'
POC: pkt-64-zep.c-86.pcap.gz
The print-ntp.c:p_ntp_time seems to have some changes compared to the print-zep.c:zep_print_ts. Both of them do the same, i.e., print ntp time stamp.
It might be good idea to take rest of the changes from that function to here too. This line seems to be solved by using int64_t first and then copying it to time_t. On the other hand, I think you will still get same warning as seconds_64bit will be negative in that case and it still will not fit the time_t... If you try same time for print-ntp.c:p_ntp_time do you get same errors.
If course we could simply change the
if (i) {
to
if (i >= JAN_1970) {