]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-decnet.c
CVE-2017-13040/MPTCP: Clean up printing DSS suboption.
[tcpdump] / print-decnet.c
index 37ff04b527b2188abe75e01ea80d6f568385c657..de7de2758ee73192769a06e9edf64cce3ebca65c 100644 (file)
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
+/* \summary: DECnet printer */
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
 
 struct mbuf;
 struct rtentry;
@@ -37,7 +39,7 @@ struct rtentry;
 #include <string.h>
 
 #include "extract.h"
-#include "interface.h"
+#include "netdissect.h"
 #include "addrtoname.h"
 
 static const char tstr[] = "[|decnet]";
@@ -324,7 +326,6 @@ union controlmsg
 #define COS_NONE 0                     /* no flow control */
 #define COS_SEGMENT 04                 /* segment flow control */
 #define COS_MESSAGE 010                        /* message flow control */
-#define COS_CRYPTSER 020               /* cryptographic services requested */
 #define COS_DEFAULT 1                  /* default value for field */
 
 #define COI_MASK 3                     /* mask for version field */
@@ -490,9 +491,6 @@ static void print_i_info(netdissect_options *, int);
 static int print_elist(const char *, u_int);
 static int print_nsp(netdissect_options *, const u_char *, u_int);
 static void print_reason(netdissect_options *, int);
-#ifdef PRINT_NSPDATA
-static void pdata(netdissect_options *, u_char *, u_int);
-#endif
 
 #ifndef HAVE_NETDNET_DNETDB_H_DNET_HTOA
 extern char *dnet_htoa(struct dn_naddr *);
@@ -544,6 +542,7 @@ decnet_print(netdissect_options *ndo,
            length -= padlen;
            caplen -= padlen;
            rhp = (const union routehdr *)&(ap[sizeof(short)]);
+           ND_TCHECK(rhp->rh_short.sh_flags);
            mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags);
        }
 
@@ -615,6 +614,7 @@ print_decnet_ctlmsg(netdissect_options *ndo,
                     register const union routehdr *rhp, u_int length,
                     u_int caplen)
 {
+       /* Our caller has already checked for mflags */
        int mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags);
        register const union controlmsg *cmp = (const union controlmsg *)rhp;
        int src, dst, info, blksize, eco, ueco, hello, other, vers;
@@ -875,9 +875,6 @@ print_nsp(netdissect_options *ndo,
                {
                    const struct seghdr *shp = (const struct seghdr *)nspp;
                    int ack;
-#ifdef PRINT_NSPDATA
-                   const u_char *dp;
-#endif
                    u_int data_off = sizeof(struct minseghdr);
 
                    if (nsplen < data_off)
@@ -907,13 +904,6 @@ print_nsp(netdissect_options *ndo,
                        }
                    }
                    ND_PRINT((ndo, "seg %d ", ack & SGQ_MASK));
-#ifdef PRINT_NSPDATA
-                   if (nsplen > data_off) {
-                       dp = &(nspp[data_off]);
-                       ND_TCHECK2(*dp, nsplen - data_off);
-                       pdata(ndo, dp, nsplen - data_off);
-                   }
-#endif
                }
                break;
            case MFS_ILS+MFS_INT:
@@ -921,9 +911,6 @@ print_nsp(netdissect_options *ndo,
                {
                    const struct seghdr *shp = (const struct seghdr *)nspp;
                    int ack;
-#ifdef PRINT_NSPDATA
-                   const u_char *dp;
-#endif
                    u_int data_off = sizeof(struct minseghdr);
 
                    if (nsplen < data_off)
@@ -953,13 +940,6 @@ print_nsp(netdissect_options *ndo,
                        }
                    }
                    ND_PRINT((ndo, "seg %d ", ack & SGQ_MASK));
-#ifdef PRINT_NSPDATA
-                   if (nsplen > data_off) {
-                       dp = &(nspp[data_off]);
-                       ND_TCHECK2(*dp, nsplen - data_off);
-                       pdata(ndo, dp, nsplen - data_off);
-                   }
-#endif
                }
                break;
            case MFS_ILS:
@@ -1099,9 +1079,6 @@ print_nsp(netdissect_options *ndo,
                {
                    const struct cimsg *cimp = (const struct cimsg *)nspp;
                    int services, info, segsize;
-#ifdef PRINT_NSPDATA
-                   const u_char *dp;
-#endif
 
                    if (nsplen < sizeof(struct cimsg))
                        goto trunc;
@@ -1119,9 +1096,6 @@ print_nsp(netdissect_options *ndo,
                    case COS_MESSAGE:
                        ND_PRINT((ndo, "msg "));
                        break;
-                   case COS_CRYPTSER:
-                       ND_PRINT((ndo, "crypt "));
-                       break;
                    }
                    switch (info & COI_MASK) {
                    case COI_32:
@@ -1138,13 +1112,6 @@ print_nsp(netdissect_options *ndo,
                        break;
                    }
                    ND_PRINT((ndo, "segsize %d ", segsize));
-#ifdef PRINT_NSPDATA
-                   if (nsplen > sizeof(struct cimsg)) {
-                       dp = &(nspp[sizeof(struct cimsg)]);
-                       ND_TCHECK2(*dp, nsplen - sizeof(struct cimsg));
-                       pdata(ndo, dp, nsplen - sizeof(struct cimsg));
-                   }
-#endif
                }
                break;
            case MFS_CC:
@@ -1153,9 +1120,6 @@ print_nsp(netdissect_options *ndo,
                    const struct ccmsg *ccmp = (const struct ccmsg *)nspp;
                    int services, info;
                    u_int segsize, optlen;
-#ifdef PRINT_NSPDATA
-                   const u_char *dp;
-#endif
 
                    if (nsplen < sizeof(struct ccmsg))
                        goto trunc;
@@ -1174,9 +1138,6 @@ print_nsp(netdissect_options *ndo,
                    case COS_MESSAGE:
                        ND_PRINT((ndo, "msg "));
                        break;
-                   case COS_CRYPTSER:
-                       ND_PRINT((ndo, "crypt "));
-                       break;
                    }
                    switch (info & COI_MASK) {
                    case COI_32:
@@ -1195,13 +1156,6 @@ print_nsp(netdissect_options *ndo,
                    ND_PRINT((ndo, "segsize %d ", segsize));
                    if (optlen) {
                        ND_PRINT((ndo, "optlen %d ", optlen));
-#ifdef PRINT_NSPDATA
-                       if (optlen > nsplen - sizeof(struct ccmsg))
-                           goto trunc;
-                       dp = &(nspp[sizeof(struct ccmsg)]);
-                       ND_TCHECK2(*dp, optlen);
-                       pdata(ndo, dp, optlen);
-#endif
                    }
                }
                break;
@@ -1211,9 +1165,6 @@ print_nsp(netdissect_options *ndo,
                    const struct dimsg *dimp = (const struct dimsg *)nspp;
                    int reason;
                    u_int optlen;
-#ifdef PRINT_NSPDATA
-                   const u_char *dp;
-#endif
 
                    if (nsplen < sizeof(struct dimsg))
                        goto trunc;
@@ -1224,13 +1175,6 @@ print_nsp(netdissect_options *ndo,
                    print_reason(ndo, reason);
                    if (optlen) {
                        ND_PRINT((ndo, "optlen %d ", optlen));
-#ifdef PRINT_NSPDATA
-                       if (optlen > nsplen - sizeof(struct dimsg))
-                           goto trunc;
-                       dp = &(nspp[sizeof(struct dimsg)]);
-                       ND_TCHECK2(*dp, optlen);
-                       pdata(ndo, dp, optlen);
-#endif
                    }
                }
                break;
@@ -1295,7 +1239,7 @@ print_reason(netdissect_options *ndo,
 }
 
 const char *
-dnnum_string(u_short dnaddr)
+dnnum_string(netdissect_options *ndo, u_short dnaddr)
 {
        char *str;
        size_t siz;
@@ -1304,13 +1248,13 @@ dnnum_string(u_short dnaddr)
 
        str = (char *)malloc(siz = sizeof("00.0000"));
        if (str == NULL)
-               error("dnnum_string: malloc");
+               (*ndo->ndo_error)(ndo, "dnnum_string: malloc");
        snprintf(str, siz, "%d.%d", area, node);
        return(str);
 }
 
 const char *
-dnname_string(u_short dnaddr)
+dnname_string(netdissect_options *ndo, u_short dnaddr)
 {
 #ifdef HAVE_DNET_HTOA
        struct dn_naddr dna;
@@ -1322,23 +1266,8 @@ dnname_string(u_short dnaddr)
        if(dnname != NULL)
                return (strdup(dnname));
        else
-               return(dnnum_string(dnaddr));
+               return(dnnum_string(ndo, dnaddr));
 #else
-       return(dnnum_string(dnaddr));   /* punt */
+       return(dnnum_string(ndo, dnaddr));      /* punt */
 #endif
 }
-
-#ifdef PRINT_NSPDATA
-static void
-pdata(netdissect_options *ndo,
-      u_char *dp, u_int maxlen)
-{
-       char c;
-       u_int x = maxlen;
-
-       while (x-- > 0) {
-           c = *dp++;
-           safeputchar(ndo, c);
-       }
-}
-#endif