]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
protodetect: handle all gaps, even when depth is reached
authorPhilippe Antoine <contact@catenacyber.fr>
Mon, 23 Aug 2021 14:31:42 +0000 (16:31 +0200)
committerVictor Julien <victor@inliniac.net>
Fri, 1 Oct 2021 06:08:50 +0000 (08:08 +0200)
src/app-layer.c
src/stream-tcp-reassemble.c

index 3b0334ced9a91cdbc6fc0de1991051e7a3b82b25..ffb8ecdb7a4564e414f9786cbc9c6556d49f6af7 100644 (file)
@@ -325,6 +325,7 @@ static int TCPProtoDetect(ThreadVars *tv,
 #endif
 
     bool reverse_flow = false;
+    DEBUG_VALIDATE_BUG_ON(data == NULL && data_len > 0);
     PACKET_PROFILING_APP_PD_START(app_tctx);
     *alproto = AppLayerProtoDetectGetProto(app_tctx->alpd_tctx,
             f, data, data_len,
index fae1a4619dc5df9ce3317734c3981f4cf45b0def..3333407d4efc41fbd68189c88c574ff30b7997df 100644 (file)
@@ -1150,7 +1150,9 @@ static int ReassembleUpdateAppLayer (ThreadVars *tv,
 
         } else if (flags & STREAM_DEPTH) {
             // we're just called once with this flag, so make sure we pass it on
-
+            if (mydata == NULL && mydata_len > 0) {
+                mydata_len = 0;
+            }
         } else if (mydata == NULL || (mydata_len == 0 && ((flags & STREAM_EOF) == 0))) {
             /* Possibly a gap, but no new data. */
             if ((p->flags & PKT_PSEUDO_STREAM_END) == 0 || ssn->state < TCP_CLOSED)
@@ -1161,6 +1163,7 @@ static int ReassembleUpdateAppLayer (ThreadVars *tv,
             SCLogDebug("%"PRIu64" got %p/%u", p->pcap_cnt, mydata, mydata_len);
             break;
         }
+        DEBUG_VALIDATE_BUG_ON(mydata == NULL && mydata_len > 0);
 
         SCLogDebug("stream %p data in buffer %p of len %u and offset %"PRIu64,
                 *stream, &(*stream)->sb, mydata_len, app_progress);