]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-zep.c
Makefile.in: don't remove configure and config.h.in in make distclean.
[tcpdump] / print-zep.c
index ac4e017c0dbf6ff75841ff0ee59c79332a181153..b18437f0c784c8eb6d1a34f8f277a484a6e120e9 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "netdissect-stdinc.h"
 
+#define ND_LONGJMP_FROM_TCHECK
 #include "netdissect.h"
 
 #include "extract.h"
@@ -76,20 +77,17 @@ static void zep_print_ts(netdissect_options *ndo, const u_char *p)
                                                billion */
        ND_PRINT("%u.%09d", i, f);
 
-#ifdef HAVE_STRFTIME
        /*
         * print the time in human-readable format.
         */
        if (i) {
                time_t seconds = i - JAN_1970;
-               struct tm *tm;
                char time_buf[128];
 
-               tm = localtime(&seconds);
-               strftime(time_buf, sizeof (time_buf), "%Y/%m/%d %H:%M:%S", tm);
-               ND_PRINT(" (%s)", time_buf);
+               ND_PRINT(" (%s)",
+                   nd_format_time(time_buf, sizeof (time_buf), "%Y/%m/%d %H:%M:%S",
+                     localtime(&seconds)));
        }
-#endif
 }
 
 /*
@@ -122,6 +120,7 @@ zep_print(netdissect_options *ndo,
 
        if (version == 1) {
                /* ZEP v1 packet. */
+               ND_ICHECK_U(len, <, 16);
                ND_PRINT("Channel ID %u, Device ID 0x%04x, ",
                         GET_U_1(bp + 3), GET_BE_U_2(bp + 4));
                if (GET_U_1(bp + 6))
@@ -137,6 +136,7 @@ zep_print(netdissect_options *ndo,
                /* ZEP v2 packet. */
                if (GET_U_1(bp + 3) == 2) {
                        /* ZEP v2 ack. */
+                       ND_ICHECK_U(len, <, 8);
                        seq_no = GET_BE_U_4(bp + 4);
                        ND_PRINT("ACK, seq# = %u", seq_no);
                        inner_len = 0;
@@ -144,6 +144,7 @@ zep_print(netdissect_options *ndo,
                        len -= 8;
                } else {
                        /* ZEP v2 data, or some other. */
+                       ND_ICHECK_U(len, <, 32);
                        ND_PRINT("Type %u, Channel ID %u, Device ID 0x%04x, ",
                                 GET_U_1(bp + 3), GET_U_1(bp + 4),
                                 GET_BE_U_2(bp + 5));
@@ -166,6 +167,7 @@ zep_print(netdissect_options *ndo,
                /* Call 802.15.4 dissector. */
                ND_PRINT("\n\t");
                if (ieee802_15_4_print(ndo, bp, inner_len)) {
+                       ND_TCHECK_LEN(bp, len);
                        bp += len;
                        len = 0;
                }
@@ -173,4 +175,7 @@ zep_print(netdissect_options *ndo,
 
        if (!ndo->ndo_suppress_default_print)
                ND_DEFAULTPRINT(bp, len);
+       return;
+invalid:
+       nd_print_invalid(ndo);
 }