]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-wb.c
Handle very large -f files by rejecting them.
[tcpdump] / print-wb.c
index 92b8c2c36691b7e2bdf2fcc94a16b87fbb76b044..f90170b80e45b45244082888c83c8451744b99f9 100644 (file)
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
+/* \summary: White Board printer */
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
 
-#include "interface.h"
+#include "netdissect.h"
 #include "addrtoname.h"
 #include "extract.h"
 
@@ -201,7 +203,7 @@ wb_id(netdissect_options *ndo,
        len -= sizeof(*io) * nid;
        io = (const struct id_off *)(id + 1);
        cp = (const char *)(io + nid);
-       if (ND_TTEST2(cp, len)) {
+       if (ND_TTEST2(*cp, len)) {
                ND_PRINT((ndo, "\""));
                fn_print(ndo, (const u_char *)cp, (const u_char *)cp + len);
                ND_PRINT((ndo, "\""));
@@ -261,9 +263,8 @@ wb_prep(netdissect_options *ndo,
        const u_char *ep = ndo->ndo_snapend;
 
        ND_PRINT((ndo, " wb-prep:"));
-       if (len < sizeof(*prep)) {
+       if (len < sizeof(*prep) || !ND_TTEST(*prep))
                return (-1);
-       }
        n = EXTRACT_32BITS(&prep->pp_n);
        ps = (const struct pgstate *)(prep + 1);
        while (--n >= 0 && ND_TTEST(*ps)) {
@@ -417,31 +418,37 @@ wb_print(netdissect_options *ndo,
        case PT_ID:
                if (wb_id(ndo, (const struct pkt_id *)(ph + 1), len) >= 0)
                        return;
+               ND_PRINT((ndo, "%s", tstr));
                break;
 
        case PT_RREQ:
                if (wb_rreq(ndo, (const struct pkt_rreq *)(ph + 1), len) >= 0)
                        return;
+               ND_PRINT((ndo, "%s", tstr));
                break;
 
        case PT_RREP:
                if (wb_rrep(ndo, (const struct pkt_rrep *)(ph + 1), len) >= 0)
                        return;
+               ND_PRINT((ndo, "%s", tstr));
                break;
 
        case PT_DRAWOP:
                if (wb_drawop(ndo, (const struct pkt_dop *)(ph + 1), len) >= 0)
                        return;
+               ND_PRINT((ndo, "%s", tstr));
                break;
 
        case PT_PREQ:
                if (wb_preq(ndo, (const struct pkt_preq *)(ph + 1), len) >= 0)
                        return;
+               ND_PRINT((ndo, "%s", tstr));
                break;
 
        case PT_PREP:
                if (wb_prep(ndo, (const struct pkt_prep *)(ph + 1), len) >= 0)
                        return;
+               ND_PRINT((ndo, "%s", tstr));
                break;
 
        default: