]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-snmp.c
remove redundant ND_TCHECK, let GET_ routines handle checks
[tcpdump] / print-snmp.c
index aa2974cc04ad8e1faa13afeb422c4673634b470f..439dc780fd96b99f4306f901df4344c2900f426e 100644 (file)
@@ -71,6 +71,8 @@
 #include <smi.h>
 #endif
 
+#include "netdissect-ctype.h"
+
 #include "netdissect.h"
 #include "extract.h"
 
@@ -197,7 +199,7 @@ static const char *ErrorStatus[] = {
 #define DECODE_ErrorStatus(e) \
        ( e >= 0 && (size_t)e < sizeof(ErrorStatus)/sizeof(ErrorStatus[0]) \
                ? ErrorStatus[e] \
-               : (nd_snprintf(errbuf, sizeof(errbuf), "err=%u", e), errbuf))
+               : (snprintf(errbuf, sizeof(errbuf), "err=%u", e), errbuf))
 
 /*
  * generic-trap values in the SNMP Trap-PDU
@@ -215,7 +217,7 @@ static const char *GenericTrap[] = {
 #define DECODE_GenericTrap(t) \
        ( t >= 0 && (size_t)t < sizeof(GenericTrap)/sizeof(GenericTrap[0]) \
                ? GenericTrap[t] \
-               : (nd_snprintf(buf, sizeof(buf), "gt=%d", t), buf))
+               : (snprintf(buf, sizeof(buf), "gt=%d", t), buf))
 
 /*
  * ASN.1 type class table
@@ -428,7 +430,6 @@ asn1_parse(netdissect_options *ndo,
                ND_PRINT("[nothing to parse]");
                return -1;
        }
-       ND_TCHECK_1(p);
 
        /*
         * it would be nice to use a bit field, but you can't depend on them.
@@ -463,7 +464,6 @@ asn1_parse(netdissect_options *ndo,
                 * that won't fit in 32 bits.
                 */
                id = 0;
-               ND_TCHECK_1(p);
                while (GET_U_1(p) & ASN_BIT8) {
                        if (len < 1) {
                                ND_PRINT("[Xtagfield?]");
@@ -473,13 +473,11 @@ asn1_parse(netdissect_options *ndo,
                        len--;
                        hdr++;
                        p++;
-                       ND_TCHECK_1(p);
                }
                if (len < 1) {
                        ND_PRINT("[Xtagfield?]");
                        return -1;
                }
-               ND_TCHECK_1(p);
                elem->id = id = (id << 7) | GET_U_1(p);
                --len;
                ++hdr;
@@ -489,7 +487,6 @@ asn1_parse(netdissect_options *ndo,
                ND_PRINT("[no asnlen]");
                return -1;
        }
-       ND_TCHECK_1(p);
        elem->asnlen = GET_U_1(p);
        p++; len--; hdr++;
        if (elem->asnlen & ASN_BIT8) {
@@ -700,7 +697,7 @@ asn1_print_string(netdissect_options *ndo, struct be *elem)
        p = elem->data.str;
        ND_TCHECK_LEN(p, asnlen);
        for (i = asnlen; printable && i != 0; p++, i--)
-               printable = ND_ISPRINT(GET_U_1(p));
+               printable = ND_ASCII_ISPRINT(GET_U_1(p));
        p = elem->data.str;
        if (printable) {
                ND_PRINT("\"");
@@ -769,7 +766,6 @@ asn1_print(netdissect_options *ndo,
                }
 
                for (; i != 0; p++, i--) {
-                       ND_TCHECK_1(p);
                        o = (o << ASN_SHIFT7) + (GET_U_1(p) & ~ASN_BIT8);
                        if (GET_U_1(p) & ASN_LONGLEN)
                                continue;
@@ -922,7 +918,6 @@ smi_decode_oid(netdissect_options *ndo,
        unsigned int firstval;
 
        for (*oidlen = 0; i != 0; p++, i--) {
-               ND_TCHECK_1(p);
                o = (o << ASN_SHIFT7) + (GET_U_1(p) & ~ASN_BIT8);
                if (GET_U_1(p) & ASN_LONGLEN)
                    continue;
@@ -946,10 +941,6 @@ smi_decode_oid(netdissect_options *ndo,
                o = 0;
        }
        return 0;
-
-trunc:
-       nd_print_trunc(ndo);
-       return -1;
 }
 
 static int smi_check_type(SmiBasetype basetype, int be)