X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/2055e39f2af0aba1ab3945ea8f3e82c614a691a3..refs/heads/coverity_scan:/print-ip6opts.c diff --git a/print-ip6opts.c b/print-ip6opts.c index 8ef94fab..ca000602 100644 --- a/print-ip6opts.c +++ b/print-ip6opts.c @@ -29,9 +29,7 @@ /* \summary: IPv6 header option printer */ -#ifdef HAVE_CONFIG_H #include -#endif #include "netdissect-stdinc.h" @@ -150,12 +148,19 @@ ip6_opt_process(netdissect_options *ndo, const u_char *bp, int len, ND_PRINT("(jumbo: %u - already seen) ", jumbolen); } else { found_jumbo = 1; - if (*payload_len != 0) { + if (payload_len == NULL) { + /* Not a hop-by-hop option - not valid */ + if (ndo->ndo_vflag) + ND_PRINT("(jumbo: %u - not a hop-by-hop option) ", jumbolen); + } else if (*payload_len != 0) { /* Payload length was non-zero - not valid */ if (ndo->ndo_vflag) ND_PRINT("(jumbo: %u - payload len != 0) ", jumbolen); } else { - /* Payload length was zero in the IPv6 header */ + /* + * This is a hop-by-hop option, and Payload length + * was zero in the IPv6 header. + */ if (jumbolen < 65536) { /* Too short */ if (ndo->ndo_vflag) @@ -180,7 +185,7 @@ ip6_opt_process(netdissect_options *ndo, const u_char *bp, int len, goto trunc; } if (ndo->ndo_vflag) { - ND_PRINT("(homeaddr: %s", ip6addr_string(ndo, bp + i + 2)); + ND_PRINT("(homeaddr: %s", GET_IP6ADDR_STRING(bp + i + 2)); if (GET_U_1(bp + i + 1) > IP6OPT_HOMEADDR_MINLEN - 2) { if (ip6_sopt_print(ndo, bp + i + IP6OPT_HOMEADDR_MINLEN, (optlen - IP6OPT_HOMEADDR_MINLEN)) == -1) @@ -215,11 +220,11 @@ hbhopt_process(netdissect_options *ndo, const u_char *bp, int *found_jumbo, const struct ip6_hbh *dp = (const struct ip6_hbh *)bp; u_int hbhlen = 0; - ndo->ndo_protocol = "hbhopt"; - ND_TCHECK_1(dp->ip6h_len); + ndo->ndo_protocol = "hbh"; hbhlen = (GET_U_1(dp->ip6h_len) + 1) << 3; ND_TCHECK_LEN(dp, hbhlen); - ND_PRINT("HBH "); + nd_print_protocol_caps(ndo); + ND_PRINT(" "); if (ip6_opt_process(ndo, (const u_char *)dp + sizeof(*dp), hbhlen - sizeof(*dp), found_jumbo, jumbolen) == -1) goto trunc; @@ -235,22 +240,20 @@ dstopt_process(netdissect_options *ndo, const u_char *bp) { const struct ip6_dest *dp = (const struct ip6_dest *)bp; u_int dstoptlen = 0; - int found_jumbo; - uint32_t jumbolen; ndo->ndo_protocol = "dstopt"; - ND_TCHECK_1(dp->ip6d_len); dstoptlen = (GET_U_1(dp->ip6d_len) + 1) << 3; ND_TCHECK_LEN(dp, dstoptlen); - ND_PRINT("DSTOPT "); + nd_print_protocol_caps(ndo); + ND_PRINT(" "); if (ndo->ndo_vflag) { /* - * The Jumbo Payload option is a hop-by-hop option; we print, - * but don't honor, Jumbo Payload destination options. + * The Jumbo Payload option is a hop-by-hop option; we don't + * honor Jumbo Payload destination options, reporting them + * as invalid. */ if (ip6_opt_process(ndo, (const u_char *)dp + sizeof(*dp), - dstoptlen - sizeof(*dp), &found_jumbo, - &jumbolen) == -1) + dstoptlen - sizeof(*dp), NULL, NULL) == -1) goto trunc; }