X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/1d881d77dfba3bc0040c5862caf3cf3a1d143639..c0af6af3011d4c55bdadf3dd76cd5fc1115c50d0:/util-print.c diff --git a/util-print.c b/util-print.c index 45da51f7..a982e86d 100644 --- a/util-print.c +++ b/util-print.c @@ -57,12 +57,8 @@ #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) { /*