X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/bef667db65b15c89ec6f1cf325b76acd3c0b8748..c39d40a767a1ae36171e5bcbf6f157ff3e80fb6c:/print-sctp.c diff --git a/print-sctp.c b/print-sctp.c index 9384a93d..6a2a5b60 100644 --- a/print-sctp.c +++ b/print-sctp.c @@ -41,6 +41,7 @@ #include "netdissect-stdinc.h" +#define ND_LONGJMP_FROM_TCHECK #include "netdissect.h" #include "addrtoname.h" #include "extract.h" @@ -467,9 +468,9 @@ sctp_print(netdissect_options *ndo, ndo->ndo_protocol = "sctp"; if (sctpPacketLength < sizeof(struct sctpHeader)) { - ND_PRINT("truncated-sctp - %ld bytes missing!", - (long)(sizeof(struct sctpHeader) - sctpPacketLength)); - return; + ND_PRINT("truncated-sctp - %zu bytes missing!", + sizeof(struct sctpHeader) - sctpPacketLength); + goto invalid; } sctpPktHdr = (const struct sctpHeader*) bp; ND_TCHECK_SIZE(sctpPktHdr); @@ -486,16 +487,15 @@ sctp_print(netdissect_options *ndo, if (ip6) { ND_PRINT("%s.%u > %s.%u: sctp", - ip6addr_string(ndo, ip6->ip6_src), + GET_IP6ADDR_STRING(ip6->ip6_src), sourcePort, - ip6addr_string(ndo, ip6->ip6_dst), + GET_IP6ADDR_STRING(ip6->ip6_dst), destPort); - } else - { + } else { ND_PRINT("%s.%u > %s.%u: sctp", - ipaddr_string(ndo, ip->ip_src), + GET_IPADDR_STRING(ip->ip_src), sourcePort, - ipaddr_string(ndo, ip->ip_dst), + GET_IPADDR_STRING(ip->ip_dst), destPort); } @@ -581,7 +581,7 @@ sctp_print(netdissect_options *ndo, if (chunkLengthRemaining < sizeof(*dataHdrPtr)) { ND_PRINT("bogus chunk length %u]", chunkLength); - return; + goto invalid; } dataHdrPtr=(const struct sctpDataPart*)bp; @@ -604,7 +604,7 @@ sctp_print(netdissect_options *ndo, payload_size = chunkLengthRemaining; if (payload_size == 0) { ND_PRINT("bogus chunk length %u]", chunkLength); - return; + goto invalid; } if (isforces) { @@ -640,7 +640,7 @@ sctp_print(netdissect_options *ndo, if (chunkLengthRemaining < sizeof(*init)) { ND_PRINT("bogus chunk length %u]", chunkLength); - return; + goto invalid; } init=(const struct sctpInitiation*)bp; ND_PRINT("[init tag: %u] ", GET_BE_U_4(init->initTag)); @@ -668,7 +668,7 @@ sctp_print(netdissect_options *ndo, if (chunkLengthRemaining < sizeof(*init)) { ND_PRINT("bogus chunk length %u]", chunkLength); - return; + goto invalid; } init=(const struct sctpInitiation*)bp; ND_PRINT("[init tag: %u] ", GET_BE_U_4(init->initTag)); @@ -699,7 +699,7 @@ sctp_print(netdissect_options *ndo, if (chunkLengthRemaining < sizeof(*sack)) { ND_PRINT("bogus chunk length %u]", chunkLength); - return; + goto invalid; } sack=(const struct sctpSelectiveAck*)bp; ND_PRINT("[cum ack %u] ", GET_BE_U_4(sack->highestConseqTSN)); @@ -717,7 +717,7 @@ sctp_print(netdissect_options *ndo, bp += sizeof(*frag), sctpPacketLengthRemaining -= sizeof(*frag), chunkLengthRemaining -= sizeof(*frag), fragNo++) { if (chunkLengthRemaining < sizeof(*frag)) { ND_PRINT("bogus chunk length %u]", chunkLength); - return; + goto invalid; } frag = (const struct sctpSelectiveFrag *)bp; ND_PRINT("\n\t\t[gap ack block #%u: start = %u, end = %u] ", @@ -732,7 +732,7 @@ sctp_print(netdissect_options *ndo, bp += 4, sctpPacketLengthRemaining -= 4, chunkLengthRemaining -= 4, tsnNo++) { if (chunkLengthRemaining < 4) { ND_PRINT("bogus chunk length %u]", chunkLength); - return; + goto invalid; } dupTSN = (const u_char *)bp; ND_PRINT("\n\t\t[dup TSN #%u: %u] ", tsnNo+1, @@ -770,7 +770,6 @@ sctp_print(netdissect_options *ndo, } } return; - -trunc: - nd_print_trunc(ndo); +invalid: + nd_print_invalid(ndo); }