Apply this to the 4 the recently converted protocols.
HOW TO USE:
Define this in a print-*.c file before including netdissect.h to make
all its ND_TCHECK*() instances longjmp(). Only do this after verifying
that every ND_TCHECK*() in the file is correct and that in every
possible case it is safe to call longjmp() without incurring resource
leaks or any other problems. If it is not safe or feasible to convert
whole file, consider converting one function at a time.
#define ND_TTEST_SIZE(p) ND_TTEST_LEN(p, sizeof(*(p)))
/* Bail out if "l" bytes from "p" were not captured */
#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
#define ND_TCHECK_LEN(p, l) if (!ND_TTEST_LEN(p, l)) goto trunc
/* Bail out if "*(p)" was not captured */
#define ND_TCHECK_SIZE(p) ND_TCHECK_LEN(p, sizeof(*(p)))
/* Bail out if "*(p)" was not captured */
#define ND_TCHECK_SIZE(p) ND_TCHECK_LEN(p, sizeof(*(p)))
#include "netdissect-stdinc.h"
#include "netdissect-stdinc.h"
+#define ND_LONGJMP_FROM_TCHECK
#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
#include "netdissect-stdinc.h"
#include "netdissect-stdinc.h"
+#define ND_LONGJMP_FROM_TCHECK
#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
}
/* cp points to the Ver/Flags octet */
}
/* cp points to the Ver/Flags octet */
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
#include "netdissect-stdinc.h"
#include "netdissect-stdinc.h"
+#define ND_LONGJMP_FROM_TCHECK
#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
* 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
* 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.
* 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.
#include "netdissect-stdinc.h"
#include "netdissect-stdinc.h"
+#define ND_LONGJMP_FROM_TCHECK
#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
hex_and_ascii_print(ndo, "\n\t ", cp, len);
else
ND_TCHECK_LEN(cp, len);
hex_and_ascii_print(ndo, "\n\t ", cp, len);
else
ND_TCHECK_LEN(cp, len);
- return;
-
-trunc:
- nd_trunc(ndo);
invalid: /* skip the undersized data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid: /* skip the undersized data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid: /* skip the undersized data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid: /* skip the undersized data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid: /* skip the undersized data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
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. */
}
/* Vendor ID is mandatory, data is optional. */
invalid: /* skip the undersized data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid: /* skip the undersized data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
ND_PRINT(", frame decoding below\n");
ether_print(ndo, cp, len, ND_BYTES_AVAILABLE_AFTER(cp), NULL, NULL);
ndo->ndo_vflag += 3;
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 */
}
/* [OF10] Section 5.2.1 */
invalid: /* skip the undersized trailing data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
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 */
}
/* [OF10] Section 5.2.2 */
invalid: /* skip the rest of queue properties */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid: /* skip the rest of queue properties */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid: /* skip the rest of queues */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
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 */
}
/* [OF10] Section 5.2.3 */
- return;
-
-trunc:
- nd_trunc(ndo);
}
/* [OF10] Section 5.2.4 */
}
/* [OF10] Section 5.2.4 */
invalid: /* skip the rest of actions */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
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 */
}
/* [OF10] Section 5.3.1 */
/* pad */
/* Always the last field, check bounds. */
ND_TCHECK_4(cp);
/* pad */
/* Always the last field, check bounds. */
ND_TCHECK_4(cp);
- return;
-
-trunc:
- nd_trunc(ndo);
}
/* [OF10] Section 5.3.5 */
}
/* [OF10] Section 5.3.5 */
invalid: /* skip the message body */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid: /* skip the message body */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid: /* skip the message body */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid: /* skip the message body */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid: /* skip the rest of flow statistics entries */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid: /* skip the rest of flow statistics entries */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid: /* skip the message body */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid: /* skip the message body */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid: /* skip the undersized trailing data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid: /* skip the undersized trailing data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid: /* skip the undersized trailing data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid: /* skip the undersized trailing data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
invalid: /* skip the undersized trailing data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid: /* skip the undersized trailing data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
}
}
ND_TCHECK_LEN(cp, len);
}
}
ND_TCHECK_LEN(cp, len);
- return;
-
-trunc:
- nd_trunc(ndo);
}
/* [OF10] Section 5.3.6 */
}
/* [OF10] Section 5.3.6 */
invalid: /* skip the rest of the message body */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
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 */
}
/* [OF10] Section 5.4.1 */
OF_CHK_FWD(1);
/* data */
of10_packet_data_print(ndo, cp, len);
OF_CHK_FWD(1);
/* data */
of10_packet_data_print(ndo, cp, len);
- return;
-
-trunc:
- nd_trunc(ndo);
}
/* [OF10] Section 5.4.2 */
}
/* [OF10] Section 5.4.2 */
nd_print_invalid(ndo);
next_message:
ND_TCHECK_LEN(cp, len);
nd_print_invalid(ndo);
next_message:
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
#include "netdissect-stdinc.h"
#include "netdissect-stdinc.h"
+#define ND_LONGJMP_FROM_TCHECK
#include "netdissect.h"
#include "extract.h"
#include "openflow.h"
#include "netdissect.h"
#include "extract.h"
#include "openflow.h"
invalid: /* fail the current packet */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
invalid: /* fail the current packet */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);