]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Update the "Error converting time" tests for packet times
authorFrancois-Xavier Le Bail <[email protected]>
Tue, 19 Mar 2024 19:49:26 +0000 (20:49 +0100)
committerfxlb <[email protected]>
Thu, 21 Mar 2024 10:52:02 +0000 (10:52 +0000)
Replace 0x80000000 mask test on tv_sec by a test on tv_sec
negative in ts_date_hmsfrac_print() and ts_unix_print().

Replace the error message by "[timestamp < 1970-01-01 00:00:00 UTC]"

util-print.c

index b5dc5aa48bcb79fd57892f80fa135a28eddccfcb..5fc48befe7f60a13f7e2081940c60b657c338477 100644 (file)
@@ -249,8 +249,8 @@ ts_date_hmsfrac_print(netdissect_options *ndo, const struct timeval *tv,
        char timebuf[32];
        const char *timestr;
 
-       if ((unsigned)tv->tv_sec & 0x80000000) {
-               ND_PRINT("[Error converting time]");
+       if (tv->tv_sec < 0) {
+               ND_PRINT("[timestamp < 1970-01-01 00:00:00 UTC]");
                return;
        }
 
@@ -277,8 +277,8 @@ ts_date_hmsfrac_print(netdissect_options *ndo, const struct timeval *tv,
 static void
 ts_unix_print(netdissect_options *ndo, const struct timeval *tv)
 {
-       if ((unsigned)tv->tv_sec & 0x80000000) {
-               ND_PRINT("[Error converting time]");
+       if (tv->tv_sec < 0) {
+               ND_PRINT("[timestamp < 1970-01-01 00:00:00 UTC]");
                return;
        }