X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/61c422a88caefe986c2bc0a7f2f3028f696fa5cd..1a04b92e365f5ed01ca38619b41bcc4fc9cbd63c:/print-hncp.c?ds=sidebyside diff --git a/print-hncp.c b/print-hncp.c index 559c7032..00ab04d1 100644 --- a/print-hncp.c +++ b/print-hncp.c @@ -207,12 +207,12 @@ print_prefix(netdissect_options *ndo, const u_char *prefix, u_int max_length) int plenbytes; char buf[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx::/128")]; - if (prefix[0] >= 96 && max_length >= IPV4_MAPPED_HEADING_LEN + 1 && + if (EXTRACT_U_1(prefix) >= 96 && max_length >= IPV4_MAPPED_HEADING_LEN + 1 && is_ipv4_mapped_address(prefix + 1)) { struct in_addr addr; u_int plen; - plen = prefix[0]-96; + plen = EXTRACT_U_1(prefix) - 96; if (32 < plen) return -1; max_length -= 1; @@ -242,7 +242,8 @@ print_dns_label(netdissect_options *ndo, { u_int length = 0; while (length < max_length) { - u_int lab_length = cp[length++]; + u_int lab_length = EXTRACT_U_1(cp + length); + length++; if (lab_length == 0) return (int)length; if (length > 1 && print) @@ -274,8 +275,8 @@ dhcpv4_print(netdissect_options *ndo, if (i + 2 > length) return -1; tlv = cp + i; - type = tlv[0]; - optlen = tlv[1]; + type = EXTRACT_U_1(tlv); + optlen = EXTRACT_U_1(tlv + 1); value = tlv + 2; ND_PRINT((ndo, "\n")); @@ -430,7 +431,7 @@ hncp_print_rec(netdissect_options *ndo, type = EXTRACT_BE_U_2(tlv); bodylen = EXTRACT_BE_U_2(tlv + 2); value = tlv + 4; - ND_TCHECK2(*value, bodylen); + ND_TCHECK_LEN(value, bodylen); if (i + bodylen + 4 > length) goto invalid; @@ -654,7 +655,7 @@ hncp_print_rec(netdissect_options *ndo, ND_PRINT((ndo, " %s", istr)); break; } - policy = value[0]; + policy = EXTRACT_U_1(value); ND_PRINT((ndo, " type: ")); if (policy == 0) { if (bodylen != 1) { @@ -729,7 +730,7 @@ hncp_print_rec(netdissect_options *ndo, ND_PRINT((ndo, " %s", istr)); break; } - prty = value[4] & 0xf; + prty = EXTRACT_U_1(value + 4) & 0xf; ND_PRINT((ndo, " EPID: %08x Prty: %u", EXTRACT_BE_U_4(value), prty @@ -807,7 +808,7 @@ hncp_print_rec(netdissect_options *ndo, ND_PRINT((ndo, " %s", istr)); break; } - l = value[16]; + l = EXTRACT_U_1(value + 16); if (bodylen < 17 + l) { ND_PRINT((ndo, " %s", istr)); break;