]> 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)
committerFrancois-Xavier Le Bail <[email protected]>
Fri, 22 Mar 2024 10:41:39 +0000 (11:41 +0100)
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]"

(cherry picked from commit b84bd2b4b55067d1eea6181e1a09043ac093d48c)

util-print.c

index 7a6bd09955a26c49d91d4dbec988783962aae16d..ec4cf743ca71630402b355d3e4958f513d78249b 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;
        }