]> The Tcpdump Group git mirrors - tcpdump/commitdiff
TCP: Update the snapend before decoding a MPTCP option
authorFrancois-Xavier Le Bail <[email protected]>
Thu, 11 Feb 2021 20:09:00 +0000 (21:09 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Fri, 12 Feb 2021 08:52:00 +0000 (09:52 +0100)
Update the snapend to the end of the option before calling mptcp_print().
Some options (MPTCP or others) may be present after a MPTCP option.
This prevents that, in mptcp_print(), the remaining length < the remaining
caplen.

print-tcp.c

index 98752f4be8fe1776a7be986d9b14455f9ba9b687..0d62c4a93bd67c981f4f12b8d7e86d510507989c 100644 (file)
@@ -612,6 +612,10 @@ tcp_print(netdissect_options *ndo,
                                 break;
 
                         case TCPOPT_MPTCP:
+                           {
+                                const u_char *snapend_save;
+                                int ret;
+
                                 datalen = len - 2;
                                 LENCHECK(datalen);
                                 /* FIXME: Proof-read mptcp_print() and if it
@@ -619,9 +623,15 @@ tcp_print(netdissect_options *ndo,
                                  * only do ND_TCHECK_LEN() if it returned 0.
                                  */
                                 ND_TCHECK_LEN(cp, datalen);
-                                if (!mptcp_print(ndo, cp-2, len, flags))
+                                snapend_save = ndo->ndo_snapend;
+                                ndo->ndo_snapend = ND_MIN(cp - 2 + len,
+                                                          ndo->ndo_snapend);
+                                ret = mptcp_print(ndo, cp - 2, len, flags);
+                                ndo->ndo_snapend = snapend_save;
+                                if (!ret)
                                         goto bad;
                                 break;
+                            }
 
                         case TCPOPT_FASTOPEN:
                                 datalen = len - 2;