]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
decode/tcp: Improved handling of TFO options 5703/head
authorJeff Lucovsky <jeff@lucovsky.org>
Tue, 5 Jan 2021 14:31:11 +0000 (09:31 -0500)
committerJeff Lucovsky <jeff@lucovsky.org>
Tue, 5 Jan 2021 14:31:11 +0000 (09:31 -0500)
This commit improves handling of TCP fast open options
- Option length must be in [6, 18]
- Option length must be an even value

src/decode-tcp.c
src/decode-tcp.h

index c3f0ad240aa307c0a612fee44dad80e40a11272c..35f59ef2fe18c191fdac6dd6230c3cdeeeb60637 100644 (file)
@@ -154,11 +154,8 @@ static void DecodeTCPOptions(Packet *p, const uint8_t *pkt, uint16_t pktlen)
                     break;
                 case TCP_OPT_TFO:
                     SCLogDebug("TFO option, len %u", olen);
-                    if ((olen != 2) &&
-                           (olen < TCP_OPT_TFO_MIN_LEN ||
-                            olen > TCP_OPT_TFO_MAX_LEN ||
-                            !((olen - 2) % 8 == 0)))
-                    {
+                    if ((olen != 2) && (olen < TCP_OPT_TFO_MIN_LEN || olen > TCP_OPT_TFO_MAX_LEN ||
+                                               !(((olen - 2) & 0x1) == 0))) {
                         ENGINE_SET_EVENT(p,TCP_OPT_INVALID_LEN);
                     } else {
                         if (p->tcpvars.tfo.type != 0) {
index 025e872860ac2a70a7157567f857de10027f35a7..7bcae94342638913d4a33191c065c5e1f481d11b 100644 (file)
@@ -62,7 +62,7 @@
 #define TCP_OPT_SACK_MIN_LEN                 10 /* hdr 2, 1 pair 8 = 10 */
 #define TCP_OPT_SACK_MAX_LEN                 34 /* hdr 2, 4 pair 32= 34 */
 #define TCP_OPT_TFO_MIN_LEN                  6  /* kind, len, 6 */
-#define TCP_OPT_TFO_MAX_LEN                  20 /* kind, len, 18 */
+#define TCP_OPT_TFO_MAX_LEN                  18 /* kind, len, 18 */
 
 /** Max valid wscale value. */
 #define TCP_WSCALE_MAX                       14