X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/7199dd316fde2a4705cb122863f5f58eb5aa0752..1a04b92e365f5ed01ca38619b41bcc4fc9cbd63c:/print-snmp.c diff --git a/print-snmp.c b/print-snmp.c index fdb3499d..976264c6 100644 --- a/print-snmp.c +++ b/print-snmp.c @@ -418,7 +418,7 @@ static const char *SnmpVersion[] = { */ static int asn1_parse(netdissect_options *ndo, - register const u_char *p, u_int len, struct be *elem) + const u_char *p, u_int len, struct be *elem) { u_char form, class, id; int i, hdr; @@ -429,7 +429,7 @@ asn1_parse(netdissect_options *ndo, ND_PRINT((ndo, "[nothing to parse]")); return -1; } - ND_TCHECK(*p); + ND_TCHECK_1(p); /* * it would be nice to use a bit field, but you can't depend on them. @@ -444,8 +444,8 @@ asn1_parse(netdissect_options *ndo, class = form >> 1; /* bits 7&6 -> bits 1&0, range 0-3 */ form &= 0x1; /* bit 5 -> bit 0, range 0-1 */ #else - form = (u_char)(*p & ASN_FORM_BITS) >> ASN_FORM_SHIFT; - class = (u_char)(*p & ASN_CLASS_BITS) >> ASN_CLASS_SHIFT; + form = (u_char)(EXTRACT_U_1(p) & ASN_FORM_BITS) >> ASN_FORM_SHIFT; + class = (u_char)(EXTRACT_U_1(p) & ASN_CLASS_BITS) >> ASN_CLASS_SHIFT; #endif elem->form = form; elem->class = class; @@ -464,23 +464,23 @@ asn1_parse(netdissect_options *ndo, * that won't fit in 32 bits. */ id = 0; - ND_TCHECK(*p); + ND_TCHECK_1(p); while (EXTRACT_U_1(p) & ASN_BIT8) { if (len < 1) { ND_PRINT((ndo, "[Xtagfield?]")); return -1; } - id = (id << 7) | (*p & ~ASN_BIT8); + id = (id << 7) | (EXTRACT_U_1(p) & ~ASN_BIT8); len--; hdr++; p++; - ND_TCHECK(*p); + ND_TCHECK_1(p); } if (len < 1) { ND_PRINT((ndo, "[Xtagfield?]")); return -1; } - ND_TCHECK(*p); + ND_TCHECK_1(p); elem->id = id = (id << 7) | EXTRACT_U_1(p); --len; ++hdr; @@ -490,8 +490,8 @@ asn1_parse(netdissect_options *ndo, ND_PRINT((ndo, "[no asnlen]")); return -1; } - ND_TCHECK(*p); - elem->asnlen = *p; + ND_TCHECK_1(p); + elem->asnlen = EXTRACT_U_1(p); p++; len--; hdr++; if (elem->asnlen & ASN_BIT8) { uint32_t noct = elem->asnlen % ASN_BIT8; @@ -500,7 +500,7 @@ asn1_parse(netdissect_options *ndo, ND_PRINT((ndo, "[asnlen? %d<%d]", len, noct)); return -1; } - ND_TCHECK2(*p, noct); + ND_TCHECK_LEN(p, noct); for (; noct-- > 0; len--, hdr++) { elem->asnlen = (elem->asnlen << ASN_SHIFT8) | EXTRACT_U_1(p); p++; @@ -522,7 +522,7 @@ asn1_parse(netdissect_options *ndo, ND_PRINT((ndo, "[id?%c/%s/%d]", *Form[form], Class[class].name, id)); return -1; } - ND_TCHECK2(*p, elem->asnlen); + ND_TCHECK_LEN(p, elem->asnlen); switch (form) { case PRIMITIVE: @@ -535,7 +535,7 @@ asn1_parse(netdissect_options *ndo, break; case INTEGER: { - register int32_t data; + int32_t data; elem->type = BE_INT; data = 0; @@ -543,7 +543,7 @@ asn1_parse(netdissect_options *ndo, ND_PRINT((ndo, "[asnlen=0]")); return -1; } - if (*p & ASN_BIT8) /* negative */ + if (EXTRACT_U_1(p) & ASN_BIT8) /* negative */ data = -1; for (i = elem->asnlen; i-- > 0; p++) data = (data << ASN_SHIFT8) | EXTRACT_U_1(p); @@ -579,7 +579,7 @@ asn1_parse(netdissect_options *ndo, case COUNTER: case GAUGE: case TIMETICKS: { - register uint32_t data; + uint32_t data; elem->type = BE_UNS; data = 0; for (i = elem->asnlen; i-- > 0; p++) @@ -589,7 +589,7 @@ asn1_parse(netdissect_options *ndo, } case COUNTER64: { - register uint64_t data64; + uint64_t data64; elem->type = BE_UNS64; data64 = 0; for (i = elem->asnlen; i-- > 0; p++) @@ -680,7 +680,7 @@ asn1_print_octets(netdissect_options *ndo, struct be *elem) uint32_t asnlen = elem->asnlen; uint32_t i; - ND_TCHECK2(*p, asnlen); + ND_TCHECK_LEN(p, asnlen); for (i = asnlen; i-- > 0; p++) ND_PRINT((ndo, "_%.2x", EXTRACT_U_1(p))); return 0; @@ -693,13 +693,13 @@ trunc: static int asn1_print_string(netdissect_options *ndo, struct be *elem) { - register int printable = 1, first = 1; + int printable = 1, first = 1; const u_char *p; uint32_t asnlen = elem->asnlen; uint32_t i; p = elem->data.str; - ND_TCHECK2(*p, asnlen); + ND_TCHECK_LEN(p, asnlen); for (i = asnlen; printable && i-- > 0; p++) printable = ND_ISPRINT(EXTRACT_U_1(p)); p = elem->data.str; @@ -756,7 +756,7 @@ asn1_print(netdissect_options *ndo, for (; a->node; a++) { if (i < a->oid_len) continue; - if (!ND_TTEST2(*p, a->oid_len)) + if (!ND_TTEST_LEN(p, a->oid_len)) continue; if (memcmp(a->oid, p, a->oid_len) == 0) { objp = a->node->child; @@ -770,9 +770,9 @@ asn1_print(netdissect_options *ndo, } for (; i-- > 0; p++) { - ND_TCHECK(*p); - o = (o << ASN_SHIFT7) + (*p & ~ASN_BIT8); - if (*p & ASN_LONGLEN) + ND_TCHECK_1(p); + o = (o << ASN_SHIFT7) + (EXTRACT_U_1(p) & ~ASN_BIT8); + if (EXTRACT_U_1(p) & ASN_LONGLEN) continue; /* @@ -823,7 +823,7 @@ asn1_print(netdissect_options *ndo, if (asnlen != ASNLEN_INETADDR) ND_PRINT((ndo, "[inetaddr len!=%d]", ASNLEN_INETADDR)); p = (const u_char *)elem->data.raw; - ND_TCHECK2(*p, asnlen); + ND_TCHECK_LEN(p, asnlen); for (i = asnlen; i-- != 0; p++) { ND_PRINT((ndo, (i == asnlen-1) ? "%u" : ".%u", EXTRACT_U_1(p))); } @@ -922,9 +922,9 @@ smi_decode_oid(netdissect_options *ndo, unsigned int firstval; for (*oidlen = 0; i-- > 0; p++) { - ND_TCHECK(*p); - o = (o << ASN_SHIFT7) + (*p & ~ASN_BIT8); - if (*p & ASN_LONGLEN) + ND_TCHECK_1(p); + o = (o << ASN_SHIFT7) + (EXTRACT_U_1(p) & ~ASN_BIT8); + if (EXTRACT_U_1(p) & ASN_LONGLEN) continue; /* @@ -1798,7 +1798,7 @@ v3msg_print(netdissect_options *ndo, ND_PRINT((ndo, "[msgFlags size %d]", elem.asnlen)); return; } - flags = elem.data.str[0]; + flags = EXTRACT_U_1(elem.data.str); if (flags != 0x00 && flags != 0x01 && flags != 0x03 && flags != 0x04 && flags != 0x05 && flags != 0x07) { ND_PRINT((ndo, "[msgFlags=0x%02X]", flags));