]> The Tcpdump Group git mirrors - tcpdump/blobdiff - util-print.c
Merge pull request #703 from nmap/update-gitignore
[tcpdump] / util-print.c
index 45da51f7407de79352f7f503c1cd88d8f0c23f92..a982e86da4deb95ec4ca2e76ec632e1a4a085b1f 100644 (file)
 #include "ascii_strcasecmp.h"
 #include "timeval-operations.h"
 
-/* invalid string to print '(invalid)' for malformed or corrupted packets */
-const char istr[] = " (invalid)";
-
 #define TOKBUFSIZE 128
 
-
 enum date_flag { WITHOUT_DATE = 0, WITH_DATE = 1 };
 enum time_flag { UTC_TIME = 0, LOCAL_TIME = 1 };
 
@@ -299,6 +295,11 @@ ts_date_hmsfrac_print(netdissect_options *ndo, int sec, int usec,
 static void
 ts_unix_print(netdissect_options *ndo, int sec, int usec)
 {
+       if ((unsigned)sec & 0x80000000) {
+               ND_PRINT("[Error converting time]");
+               return;
+       }
+
        ND_PRINT("%u", (unsigned)sec);
        ts_frac_print(ndo, usec);
 }
@@ -444,6 +445,12 @@ void nd_print_trunc(netdissect_options *ndo)
        ND_PRINT(" [|%s]", ndo->ndo_protocol);
 }
 
+/* Print the invalid string */
+void nd_print_invalid(netdissect_options *ndo)
+{
+       ND_PRINT(" (invalid)");
+}
+
 /*
  *  this is a generic routine for printing unknown data;
  *  we pass on the linefeed plus indentation string to
@@ -890,7 +897,7 @@ txtproto_print(netdissect_options *ndo, const u_char *pptr, u_int len,
 
        /* Capitalize the protocol name */
        for (pnp = protoname; *pnp != '\0'; pnp++)
-               ND_PRINT("%c", toupper((u_char)*pnp));
+               ND_PRINT("%c", ND_TOUPPER((u_char)*pnp));
 
        if (print_this) {
                /*