diff --git a/netdissect.h b/netdissect.h index 3b9aaf4b..b87b76a7 100644 --- a/netdissect.h +++ b/netdissect.h @@ -362,7 +362,11 @@ extern void nd_pop_all_packet_info(netdissect_options *); #define ND_TTEST_SIZE(p) ND_TTEST_LEN(p, sizeof(*(p))) /* Bail out if "l" bytes from "p" were not captured */ +#ifdef ND_LONGJMP_FROM_TCHECK +#define ND_TCHECK_LEN(p, l) if (!ND_TTEST_LEN(p, l)) nd_trunc(ndo) +#else #define ND_TCHECK_LEN(p, l) if (!ND_TTEST_LEN(p, l)) goto trunc +#endif /* Bail out if "*(p)" was not captured */ #define ND_TCHECK_SIZE(p) ND_TCHECK_LEN(p, sizeof(*(p))) diff --git a/print-ahcp.c b/print-ahcp.c index 8529b860..9859f760 100644 --- a/print-ahcp.c +++ b/print-ahcp.c @@ -35,6 +35,7 @@ #include "netdissect-stdinc.h" +#define ND_LONGJMP_FROM_TCHECK #include "netdissect.h" #include "extract.h" #include "addrtoname.h" @@ -118,9 +119,6 @@ ahcp_time_print(netdissect_options *ndo, invalid: nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } static void @@ -135,9 +133,6 @@ ahcp_seconds_print(netdissect_options *ndo, invalid: nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } static void @@ -159,9 +154,6 @@ ahcp_ipv6_addresses_print(netdissect_options *ndo, invalid: nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } static void @@ -183,9 +175,6 @@ ahcp_ipv4_addresses_print(netdissect_options *ndo, invalid: nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } static void @@ -207,9 +196,6 @@ ahcp_ipv6_prefixes_print(netdissect_options *ndo, invalid: nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } static void @@ -231,9 +217,6 @@ ahcp_ipv4_prefixes_print(netdissect_options *ndo, invalid: nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } static void @@ -291,9 +274,6 @@ ahcp1_options_print(netdissect_options *ndo, invalid: nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } static void @@ -338,9 +318,7 @@ ahcp1_body_print(netdissect_options *ndo, invalid: nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); + } void @@ -407,7 +385,4 @@ ahcp_print(netdissect_options *ndo, invalid: nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } diff --git a/print-aoe.c b/print-aoe.c index 558eeae2..41f54b99 100644 --- a/print-aoe.c +++ b/print-aoe.c @@ -37,6 +37,7 @@ #include "netdissect-stdinc.h" +#define ND_LONGJMP_FROM_TCHECK #include "netdissect.h" #include "extract.h" #include "addrtoname.h" @@ -198,9 +199,6 @@ aoev1_issue_print(netdissect_options *ndo, invalid: nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } static void @@ -244,9 +242,6 @@ aoev1_query_print(netdissect_options *ndo, invalid: nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } static void @@ -297,9 +292,6 @@ aoev1_mac_print(netdissect_options *ndo, invalid: nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } static void @@ -333,9 +325,6 @@ aoev1_reserve_print(netdissect_options *ndo, invalid: nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } /* cp points to the Ver/Flags octet */ @@ -392,9 +381,6 @@ aoev1_print(netdissect_options *ndo, invalid: nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } void @@ -423,8 +409,5 @@ aoe_print(netdissect_options *ndo, invalid: nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } diff --git a/print-loopback.c b/print-loopback.c index e9d0b1a2..ee0caf3c 100644 --- a/print-loopback.c +++ b/print-loopback.c @@ -38,6 +38,7 @@ #include "netdissect-stdinc.h" +#define ND_LONGJMP_FROM_TCHECK #include "netdissect.h" #include "extract.h" #include "addrtoname.h" @@ -98,9 +99,6 @@ loopback_message_print(netdissect_options *ndo, invalid: nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } void @@ -133,8 +131,5 @@ loopback_print(netdissect_options *ndo, invalid: nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } diff --git a/print-openflow-1.0.c b/print-openflow-1.0.c index 557d1e9c..567a8953 100644 --- a/print-openflow-1.0.c +++ b/print-openflow-1.0.c @@ -14,7 +14,7 @@ * The convention is that a printer function returns iff the given structure is * completely within the packet buffer; otherwise it processes the part that is * within the buffer, sooner of later takes the "truncated packet" shortcut via - * nd_trunc() and never returns. With that in mind, the function may return + * longjmp() and never returns. With that in mind, the function may return * without printing the structure completely if it is invalid or the ndo_vflag * value is not high enough. This way the calling function can try to decode * the next data item. @@ -65,6 +65,7 @@ #include "netdissect-stdinc.h" +#define ND_LONGJMP_FROM_TCHECK #include "netdissect.h" #include "extract.h" #include "addrtoname.h" @@ -735,10 +736,6 @@ of10_data_print(netdissect_options *ndo, hex_and_ascii_print(ndo, "\n\t ", cp, len); else ND_TCHECK_LEN(cp, len); - return; - -trunc: - nd_trunc(ndo); } static void @@ -919,9 +916,6 @@ of10_bsn_message_print(netdissect_options *ndo, invalid: /* skip the undersized data */ nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } static void @@ -986,9 +980,6 @@ of10_bsn_actions_print(netdissect_options *ndo, invalid: nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } static void @@ -1014,9 +1005,6 @@ of10_vendor_action_print(netdissect_options *ndo, invalid: /* skip the undersized data */ nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } static void @@ -1042,9 +1030,6 @@ of10_vendor_message_print(netdissect_options *ndo, invalid: /* skip the undersized data */ nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } /* Vendor ID is mandatory, data is optional. */ @@ -1067,9 +1052,6 @@ of10_vendor_data_print(netdissect_options *ndo, invalid: /* skip the undersized data */ nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } static void @@ -1088,10 +1070,6 @@ of10_packet_data_print(netdissect_options *ndo, ND_PRINT(", frame decoding below\n"); ether_print(ndo, cp, len, ND_BYTES_AVAILABLE_AFTER(cp), NULL, NULL); ndo->ndo_vflag += 3; - return; - -trunc: - nd_trunc(ndo); } /* [OF10] Section 5.2.1 */ @@ -1149,9 +1127,6 @@ of10_phy_ports_print(netdissect_options *ndo, invalid: /* skip the undersized trailing data */ nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } /* [OF10] Section 5.2.2 */ @@ -1219,9 +1194,6 @@ of10_queue_props_print(netdissect_options *ndo, invalid: /* skip the rest of queue properties */ nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } /* ibid */ @@ -1258,9 +1230,6 @@ of10_queues_print(netdissect_options *ndo, invalid: /* skip the rest of queues */ nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } /* [OF10] Section 5.2.3 */ @@ -1349,10 +1318,6 @@ of10_match_print(netdissect_options *ndo, } else ND_TCHECK_2(cp); - return; - -trunc: - nd_trunc(ndo); } /* [OF10] Section 5.2.4 */ @@ -1514,9 +1479,6 @@ of10_actions_print(netdissect_options *ndo, invalid: /* skip the rest of actions */ nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } /* [OF10] Section 5.3.1 */ @@ -1621,10 +1583,6 @@ of10_port_mod_print(netdissect_options *ndo, /* pad */ /* Always the last field, check bounds. */ ND_TCHECK_4(cp); - return; - -trunc: - nd_trunc(ndo); } /* [OF10] Section 5.3.5 */ @@ -1700,9 +1658,6 @@ of10_stats_request_print(netdissect_options *ndo, invalid: /* skip the message body */ nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } /* ibid */ @@ -1741,9 +1696,6 @@ of10_desc_stats_reply_print(netdissect_options *ndo, invalid: /* skip the message body */ nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } /* ibid */ @@ -1806,9 +1758,6 @@ of10_flow_stats_reply_print(netdissect_options *ndo, invalid: /* skip the rest of flow statistics entries */ nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } /* ibid */ @@ -1835,9 +1784,6 @@ of10_aggregate_stats_reply_print(netdissect_options *ndo, invalid: /* skip the message body */ nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } /* ibid */ @@ -1881,9 +1827,6 @@ of10_table_stats_reply_print(netdissect_options *ndo, invalid: /* skip the undersized trailing data */ nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } /* ibid */ @@ -1946,9 +1889,6 @@ of10_port_stats_reply_print(netdissect_options *ndo, invalid: /* skip the undersized trailing data */ nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } /* ibid */ @@ -1983,9 +1923,6 @@ of10_queue_stats_reply_print(netdissect_options *ndo, invalid: /* skip the undersized trailing data */ nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } /* ibid */ @@ -2020,10 +1957,6 @@ of10_stats_reply_print(netdissect_options *ndo, } } ND_TCHECK_LEN(cp, len); - return; - -trunc: - nd_trunc(ndo); } /* [OF10] Section 5.3.6 */ @@ -2054,9 +1987,6 @@ of10_packet_out_print(netdissect_options *ndo, invalid: /* skip the rest of the message body */ nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } /* [OF10] Section 5.4.1 */ @@ -2083,10 +2013,6 @@ of10_packet_in_print(netdissect_options *ndo, OF_CHK_FWD(1); /* data */ of10_packet_data_print(ndo, cp, len); - return; - -trunc: - nd_trunc(ndo); } /* [OF10] Section 5.4.2 */ @@ -2356,7 +2282,4 @@ invalid: /* skip the message body */ nd_print_invalid(ndo); next_message: ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); } diff --git a/print-openflow.c b/print-openflow.c index 3b85dd7a..f56b0a35 100644 --- a/print-openflow.c +++ b/print-openflow.c @@ -38,6 +38,7 @@ #include "netdissect-stdinc.h" +#define ND_LONGJMP_FROM_TCHECK #include "netdissect.h" #include "extract.h" #include "openflow.h" @@ -152,7 +153,4 @@ openflow_print(netdissect_options *ndo, const u_char *cp, u_int len) invalid: /* fail the current packet */ nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); - return; -trunc: - nd_trunc(ndo); }