]> The Tcpdump Group git mirrors - tcpdump/blobdiff - util-print.c
CI: Add warning exemptions for Sun C (suncc-5.14) on Solaris 10
[tcpdump] / util-print.c
index 71674221d1dca55a422c7865e12dcb7fd5f8328e..594327012e8626e7b3cb04f77fdd3120be468308 100644 (file)
@@ -216,10 +216,14 @@ ts_frac_print(netdissect_options *ndo, const struct timeval *tv)
 
        case PCAP_TSTAMP_PRECISION_MICRO:
                ND_PRINT(".%06u", (unsigned)tv->tv_usec);
+               if ((unsigned)tv->tv_usec > ND_MICRO_PER_SEC - 1)
+                       ND_PRINT(" " ND_INVALID_MICRO_SEC_STR);
                break;
 
        case PCAP_TSTAMP_PRECISION_NANO:
                ND_PRINT(".%09u", (unsigned)tv->tv_usec);
+               if ((unsigned)tv->tv_usec > ND_NANO_PER_SEC - 1)
+                       ND_PRINT(" " ND_INVALID_NANO_SEC_STR);
                break;
 
        default:
@@ -228,6 +232,8 @@ ts_frac_print(netdissect_options *ndo, const struct timeval *tv)
        }
 #else
        ND_PRINT(".%06u", (unsigned)tv->tv_usec);
+       if ((unsigned)tv->tv_usec > ND_MICRO_PER_SEC - 1)
+               ND_PRINT(" " ND_INVALID_MICRO_SEC_STR);
 #endif
 }
 
@@ -248,7 +254,7 @@ ts_date_hmsfrac_print(netdissect_options *ndo, const struct timeval *tv,
 #endif
 
        if (tv->tv_sec < 0) {
-               ND_PRINT("[timestamp < 1970-01-01 00:00:00 UTC]");
+               ND_PRINT("[timestamp overflow]");
                return;
        }
 
@@ -289,11 +295,11 @@ static void
 ts_unix_print(netdissect_options *ndo, const struct timeval *tv)
 {
        if (tv->tv_sec < 0) {
-               ND_PRINT("[timestamp < 1970-01-01 00:00:00 UTC]");
+               ND_PRINT("[timestamp overflow]");
                return;
        }
 
-       ND_PRINT("%u", (unsigned)tv->tv_sec);
+       ND_PRINT("%" PRId64, (int64_t)tv->tv_sec);
        ts_frac_print(ndo, tv);
 }
 
@@ -475,6 +481,23 @@ void nd_print_invalid(netdissect_options *ndo)
        ND_PRINT(" (invalid)");
 }
 
+/*
+ * Print a sequence of bytes, separated by a single space.
+ * Stop if truncated (via GET_U_1/longjmp) or after n bytes,
+ * whichever is first.
+ */
+void
+nd_print_bytes_hex(netdissect_options *ndo, const u_char *cp, u_int n)
+{
+       while (n > 0) {
+               ND_PRINT("%02x", GET_U_1(cp));
+               n--;
+               cp++;
+               if (n > 0)
+                       ND_PRINT(" ");
+       }
+}
+
 /*
  *  this is a generic routine for printing unknown data;
  *  we pass on the linefeed plus indentation string to