uint16_t magic;
int rev;
const struct ip6_hdr *ip6;
+ u_int header_len; /* Header length in bytes */
ndo->ndo_protocol = "tcp";
tp = (const struct tcphdr *)bp;
break;
case TCPOPT_MPTCP:
- {
+ {
const u_char *snapend_save;
int ret;
/*
* Decode payload if necessary.
*/
- bp += TH_OFF(tp) * 4;
+ header_len = TH_OFF(tp) * 4;
+ /*
+ * Do a bounds check before decoding the payload.
+ * At least the header data is required.
+ */
+ if (!ND_TTEST_LEN(bp, header_len)) {
+ ND_PRINT(" [remaining caplen(%u) < header length(%u)]",
+ ND_BYTES_AVAILABLE_AFTER(bp), header_len);
+ nd_trunc_longjmp(ndo);
+ }
+ bp += header_len;
if ((flags & TH_RST) && ndo->ndo_vflag) {
print_tcp_rst_data(ndo, bp, length);
return;
1 05:27:12.808464432 unknown ip 3
- 2 05:27:12.808464432 IP6 3030:3030:3030:3030:3030:3030:3030:3030.10288 > 3030:3030:3030:3030:3030:3030:3030:3030.12336: Flags [.U], seq 808464432:808476740, ack 808464432, win 12336, urg 12336, options [eol], length 12308 BEEP (payload or undecoded)
+ 2 05:27:12.808464432 IP6 3030:3030:3030:3030:3030:3030:3030:3030.10288 > 3030:3030:3030:3030:3030:3030:3030:3030.12336: Flags [.U], seq 808464432:808476740, ack 808464432, win 12336, urg 12336, options [eol], length 12308 [remaining caplen(24) < header length(28)] [|tcp]